﻿using System;
using System.Collections.Generic;
using System.Reflection;
using System.Resources;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using Converter;
using csla4Skeleton.UI.SL.Resources.Utility;
using csla4Skeleton.UI.SL.DanhMuc.DM_NhaCungCap;
using csla4Skeleton.UI.SL.NghiepVu.MuaSanPham.DM_PhuongThucThanhToan;
using csla4Skeleton.UI.SL.NghiepVu.MuaSanPham.DM_LoaiHoaDon;
using csla4Skeleton.UI.SL.NghiepVu.MuaSanPham.DM_LoaiMuaSanPham;
using csla4Skeleton.UI.SL.NghiepVu.MuaSanPham.DM_LoaiTienTe;
using csla4Skeleton.UI.SL.NghiepVu.TienMat.TM_PhieuChi;
using csla4Skeleton.UI.SL.DanhMuc.DM_HangHoa;
using csla4Skeleton.UI.SL.DanhMuc.DM_Kho;
using csla4Skeleton.UI.SL.DanhMuc.DM_TaiKhoan;
using csla4Skeleton.UI.SL.DanhMuc.DM_DonViTinh;
using csla4Skeleton.UI.SL.DanhMuc.DM_ThueSuat;
using csla4Skeleton.UI.SL.DanhMuc.DM_TinhChatHangHoa;
using csla4Skeleton.UI.SL.NghiepVu.Kho.K_PhieuNhapKho;
using Accounting.Library;
using Telerik.Windows.Controls;
using Telerik.Windows.Controls.GridView;
using System.ComponentModel;
using Utility;
using Accounting.Library.Utility;
using ConfigurationNghiepVu;
namespace csla4Skeleton.UI.SL.NghiepVu.MuaSanPham.MSP_MuaHangHoa
{
    public partial class MSP_MuaHangHoa_MainWindow: UserControl, Csla.Xaml.ISupportNavigation
    {

        #region ISupportNavigation Members
        List<Control> controls = new List<Control>();
        public bool CreateBookmarkAfterLoadCompleted
        {
            get { return true; }
        }

        public event EventHandler LoadCompleted;

        protected virtual void OnLoadCompleted()
        {
            if (LoadCompleted != null)
                LoadCompleted(this, EventArgs.Empty);
        }

        public void SetParameters(string parameters)
        {
            try
            {
                if (parameters == "")
                    Khoa = null;
                else
                    Khoa = Int32.Parse(parameters);
            }
            catch
            {
                Khoa = null;
            }
        }

        public string Title
        {
            get { return "MuaHangHoa"; }
        }

       
        #endregion

        #region Load Methods
        private System.Nullable<int> Khoa = null;
      
        public MSP_MuaHangHoa_MainWindow(int Khoa)          
        {
            this.Khoa = Khoa;
        }
        public delegate void KeyUp_EventHandler(object sender, KeyEventArgs e);

        public MSP_MuaHangHoa_MainWindow()
        {
            LocalizationConverter converter = new LocalizationConverter();
            converter.LocalResourceManager = new ResourceManager("csla4Skeleton.UI.SL.NghiepVu.MuaSanPham.MSP_MuaHangHoa.Resources", Assembly.GetExecutingAssembly());
            this.Resources.Add("Localization", converter);
            
            InitializeComponent();
            ControlBehavior.ControlBehaviors.Navigation(this.MSP_MuaHangHoa_GeneralInformation_GroupBox, controls);
            ControlBehavior.ControlBehaviors.Navigation(this.MSP_MuaHangHoa_MoreInformation_GroupBox, controls);
           

            
        }

        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
            {
                
                System.Windows.Data.CollectionViewSource msp_MuaHangHoa_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["MSP_MuaHangHoa_ViewModelSource"];
                if (Khoa == null)
                {
                    MSP_MuaHangHoa_ViewModel msp_MuaHangHoa_ViewModel = new MSP_MuaHangHoa_ViewModel();
                    msp_MuaHangHoa_ViewModel.ChildList_AddedNew += new MSP_MuaHangHoa_ViewModel.ChildList_AddedNew_EventHandler(msp_MuaHangHoa_ViewModel_ChildList_AddedNew);
                    msp_MuaHangHoa_ViewModel.stateChanged += new MSP_MuaHangHoa_ViewModel.DKNV_EventHandler(msp_MuaHangHoa_StateChanged);
                    msp_MuaHangHoa_ViewModel.TCHangHoaChanged += new EventHandler(msp_MuaHangHoa_TinhChatHangHoaChanged);
                    msp_MuaHangHoa_ViewModel.hangHoaIdChanged += new MSP_MuaHangHoa_ViewModel.HangHoaIdChanged_EventHandler(msp_MuaHangHoa_HangHoaIdChanged);
                    msp_MuaHangHoa_ViewModel.TKCoIdChanged += new MSP_MuaHangHoa_ViewModel.TKCoIdChanged_EventHandler(msp_MuaHangHoa_TKCoChanged);
                    msp_MuaHangHoa_ViewModel.EnableButtonLapPhieu += new EventHandler(msp_MuaHangHoa_EnableButtonLapPhieu);
                    msp_MuaHangHoa_ViewModel.LoaiTienTeChanged += new EventHandler(msp_MuaHangHoa_LoaiTienTeChanged);
                    msp_MuaHangHoa_ViewModel.ThueSuatIdChanged += new MSP_MuaHangHoa_ViewModel.ThueSuatIdChanged_EventHandler(msp_MuaHangHoa_ThueSuatIdChanged);
                    msp_MuaHangHoa_CollectionViewSource.Source = new List<object> { msp_MuaHangHoa_ViewModel };

                    
                }
                else
                {
                    MSP_MuaHangHoa_ViewModel msp_MuaHangHoa_ViewModel = new MSP_MuaHangHoa_ViewModel((int)Khoa);
                    msp_MuaHangHoa_ViewModel.ChildList_AddedNew += new MSP_MuaHangHoa_ViewModel.ChildList_AddedNew_EventHandler(msp_MuaHangHoa_ViewModel_ChildList_AddedNew);
                    msp_MuaHangHoa_ViewModel.stateChanged += new MSP_MuaHangHoa_ViewModel.DKNV_EventHandler(msp_MuaHangHoa_StateChanged);
                    msp_MuaHangHoa_ViewModel.TCHangHoaChanged += new EventHandler(msp_MuaHangHoa_TinhChatHangHoaChanged);
                    msp_MuaHangHoa_ViewModel.hangHoaIdChanged += new MSP_MuaHangHoa_ViewModel.HangHoaIdChanged_EventHandler(msp_MuaHangHoa_HangHoaIdChanged);
                    msp_MuaHangHoa_ViewModel.TKCoIdChanged += new MSP_MuaHangHoa_ViewModel.TKCoIdChanged_EventHandler(msp_MuaHangHoa_TKCoChanged);
                    msp_MuaHangHoa_ViewModel.LoaiTienTeChanged += new EventHandler(msp_MuaHangHoa_LoaiTienTeChanged);
                    msp_MuaHangHoa_ViewModel.EnableButtonLapPhieu += new EventHandler(msp_MuaHangHoa_EnableButtonLapPhieu);
                    msp_MuaHangHoa_ViewModel.ThueSuatIdChanged += new MSP_MuaHangHoa_ViewModel.ThueSuatIdChanged_EventHandler(msp_MuaHangHoa_ThueSuatIdChanged);
                    msp_MuaHangHoa_ViewModel.LoadCompleted += new EventHandler(OnMuaHangHoaLoadCompleteted);
                    msp_MuaHangHoa_CollectionViewSource.Source = new List<object> { msp_MuaHangHoa_ViewModel };

                    
                }

               


                System.Windows.Data.CollectionViewSource dm_NhaCungCap_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_NhaCungCap_ListViewModelSource"];
                DM_NhaCungCap_ListViewModel dm_NhaCungCap_ListViewModel = new DM_NhaCungCap_ListViewModel(BusinessConfiguration.Configuration.ComboboxFetchMode, BusinessConfiguration.Configuration.DieuKienLocNCC_NhaCungCap);
                dm_NhaCungCap_CollectionViewSource.Source = new List<object> { dm_NhaCungCap_ListViewModel };

                System.Windows.Data.CollectionViewSource dm_PhuongThucThanhToan_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_PhuongThucThanhToan_ListViewModelSource"];
                DM_PhuongThucThanhToan_ListViewModel dm_PhuongThucThanhToan_ListViewModel = new DM_PhuongThucThanhToan_ListViewModel(BusinessConfiguration.Configuration.ComboboxFetchMode);
                dm_PhuongThucThanhToan_CollectionViewSource.Source = new List<object> { dm_PhuongThucThanhToan_ListViewModel };

                System.Windows.Data.CollectionViewSource dm_LoaiHoaDon_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_LoaiHoaDon_ListViewModelSource"];
                DM_LoaiHoaDon_ListViewModel dm_LoaiHoaDon_ListViewModel = new DM_LoaiHoaDon_ListViewModel(BusinessConfiguration.Configuration.ComboboxFetchMode);
                dm_LoaiHoaDon_CollectionViewSource.Source = new List<object> { dm_LoaiHoaDon_ListViewModel };

                System.Windows.Data.CollectionViewSource dm_LoaiMuaSanPham_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_LoaiMuaSanPham_ListViewModelSource"];
                DM_LoaiMuaSanPham_ListViewModel dm_LoaiMuaSanPham_ListViewModel = new DM_LoaiMuaSanPham_ListViewModel(BusinessConfiguration.Configuration.ComboboxFetchMode);
                dm_LoaiMuaSanPham_CollectionViewSource.Source = new List<object> { dm_LoaiMuaSanPham_ListViewModel };

                System.Windows.Data.CollectionViewSource dm_LoaiTienTe_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_LoaiTienTe_ListViewModelSource"];
                DM_LoaiTienTe_ListViewModel dm_LoaiTienTe_ListViewModel = new DM_LoaiTienTe_ListViewModel(BusinessConfiguration.Configuration.ComboboxFetchMode);
                dm_LoaiTienTe_CollectionViewSource.Source = new List<object> { dm_LoaiTienTe_ListViewModel };


                System.Windows.Data.CollectionViewSource dm_Kho_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_Kho_ListViewModelSource"];
                DM_Kho_ListViewModel dm_Kho_ListViewModel = new DM_Kho_ListViewModel(BusinessConfiguration.Configuration.ComboboxFetchMode);
                dm_Kho_CollectionViewSource.Source = new List<object> { dm_Kho_ListViewModel };

               


                System.Windows.Data.CollectionViewSource dm_DonViTinh_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_DonViTinh_ListViewModelSource"];
                DM_DonViTinh_ListViewModel dm_DonViTinh_ListViewModel = new DM_DonViTinh_ListViewModel(BusinessConfiguration.Configuration.ComboboxFetchMode);
                dm_DonViTinh_CollectionViewSource.Source = new List<object> { dm_DonViTinh_ListViewModel };

                System.Windows.Data.CollectionViewSource dm_ThueSuat_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_ThueSuat_ListViewModelSource"];
                DM_ThueSuat_ListViewModel dm_ThueSuat_ListViewModel = new DM_ThueSuat_ListViewModel(BusinessConfiguration.Configuration.ComboboxFetchMode);
                dm_ThueSuat_CollectionViewSource.Source = new List<object> { dm_ThueSuat_ListViewModel };

                System.Windows.Data.CollectionViewSource dm_TinhChatHangHoa_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TinhChatHangHoa_ListViewModelSource"];
                DM_TinhChatHangHoa_ListViewModel dm_TinhChatHangHoa_ListViewModel = new DM_TinhChatHangHoa_ListViewModel(BusinessConfiguration.Configuration.ComboboxFetchMode);
                dm_TinhChatHangHoa_CollectionViewSource.Source = new List<object> { dm_TinhChatHangHoa_ListViewModel };

              

                DoFilterOnDefaultDKNV1();

                System.Windows.Data.CollectionViewSource dm_TaiKhoanKho_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanKho_ListViewModelSource"];
                DM_TaiKhoan_ListViewModel dm_TaiKhoanKho_ListViewModel = new DM_TaiKhoan_ListViewModel(BusinessConfiguration.Configuration.ComboboxFetchMode);
                dm_TaiKhoanKho_CollectionViewSource.Source = new List<object> { dm_TaiKhoanKho_ListViewModel };
               
                DoFilterOnDefaultDM_SanPham();

                this.MSP_MuaHangHoa_MuaHangHoaChiTietGridView.KeyboardCommandProvider = new ControlBehavior.GridViewKeyboardCommandProvider(this.MSP_MuaHangHoa_MuaHangHoaChiTietGridView);
                this.MSP_MuaHangHoa_ThueChiTietGridView.KeyboardCommandProvider = new ControlBehavior.GridViewKeyboardCommandProvider(this.MSP_MuaHangHoa_ThueChiTietGridView);
                this.MSP_MuaHangHoa_ChiPhiMuaHangGridView.KeyboardCommandProvider = new ControlBehavior.GridViewKeyboardCommandProvider(this.MSP_MuaHangHoa_ChiPhiMuaHangGridView);
                this.MSP_MuaHangHoa_TSThieuCXLGridView.KeyboardCommandProvider = new ControlBehavior.GridViewKeyboardCommandProvider(this.MSP_MuaHangHoa_TSThieuCXLGridView);
                this.MSP_MuaHangHoa_TSThuaCXLGridView.KeyboardCommandProvider = new ControlBehavior.GridViewKeyboardCommandProvider(this.MSP_MuaHangHoa_TSThuaCXLGridView);
                this.MSP_MuaHangHoa_ThueNKGridView.KeyboardCommandProvider = new ControlBehavior.GridViewKeyboardCommandProvider(this.MSP_MuaHangHoa_ThueNKGridView);
                this.MSP_MuaHangHoa_ThueTTDBGridView.KeyboardCommandProvider = new ControlBehavior.GridViewKeyboardCommandProvider(this.MSP_MuaHangHoa_ThueTTDBGridView);

                ((ControlBehavior.GridViewKeyboardCommandProvider)this.MSP_MuaHangHoa_MuaHangHoaChiTietGridView.KeyboardCommandProvider).ReachLastColumn += new ControlBehavior.GridViewKeyboardCommandProvider.ReachLastColumn_EventHandler(OnReachLastColumn);
                ((ControlBehavior.GridViewKeyboardCommandProvider)this.MSP_MuaHangHoa_ThueChiTietGridView.KeyboardCommandProvider).ReachLastColumn += new ControlBehavior.GridViewKeyboardCommandProvider.ReachLastColumn_EventHandler(OnReachLastColumn);
                ((ControlBehavior.GridViewKeyboardCommandProvider)this.MSP_MuaHangHoa_ChiPhiMuaHangGridView.KeyboardCommandProvider).ReachLastColumn += new ControlBehavior.GridViewKeyboardCommandProvider.ReachLastColumn_EventHandler(OnReachLastColumn);
                ((ControlBehavior.GridViewKeyboardCommandProvider)this.MSP_MuaHangHoa_TSThieuCXLGridView.KeyboardCommandProvider).ReachLastColumn += new ControlBehavior.GridViewKeyboardCommandProvider.ReachLastColumn_EventHandler(OnReachLastColumn);
                ((ControlBehavior.GridViewKeyboardCommandProvider)this.MSP_MuaHangHoa_TSThuaCXLGridView.KeyboardCommandProvider).ReachLastColumn += new ControlBehavior.GridViewKeyboardCommandProvider.ReachLastColumn_EventHandler(OnReachLastColumn);
                ((ControlBehavior.GridViewKeyboardCommandProvider)this.MSP_MuaHangHoa_ThueNKGridView.KeyboardCommandProvider).ReachLastColumn += new ControlBehavior.GridViewKeyboardCommandProvider.ReachLastColumn_EventHandler(OnReachLastColumn);
                ((ControlBehavior.GridViewKeyboardCommandProvider)this.MSP_MuaHangHoa_ThueTTDBGridView.KeyboardCommandProvider).ReachLastColumn += new ControlBehavior.GridViewKeyboardCommandProvider.ReachLastColumn_EventHandler(OnReachLastColumn);

                ((ControlBehavior.GridViewKeyboardCommandProvider)this.MSP_MuaHangHoa_MuaHangHoaChiTietGridView.KeyboardCommandProvider).TabKeyPress += new EventHandler (OnTabKeyPress);
                ((ControlBehavior.GridViewKeyboardCommandProvider)this.MSP_MuaHangHoa_ThueChiTietGridView.KeyboardCommandProvider).TabKeyPress += new EventHandler(OnTabKeyPress);
                ((ControlBehavior.GridViewKeyboardCommandProvider)this.MSP_MuaHangHoa_ChiPhiMuaHangGridView.KeyboardCommandProvider).TabKeyPress += new EventHandler(OnTabKeyPress);
                ((ControlBehavior.GridViewKeyboardCommandProvider)this.MSP_MuaHangHoa_TSThieuCXLGridView.KeyboardCommandProvider).TabKeyPress += new EventHandler(OnTabKeyPress);
                ((ControlBehavior.GridViewKeyboardCommandProvider)this.MSP_MuaHangHoa_TSThuaCXLGridView.KeyboardCommandProvider).TabKeyPress += new EventHandler(OnTabKeyPress);
                ((ControlBehavior.GridViewKeyboardCommandProvider)this.MSP_MuaHangHoa_ThueNKGridView.KeyboardCommandProvider).TabKeyPress += new EventHandler(OnTabKeyPress);
                ((ControlBehavior.GridViewKeyboardCommandProvider)this.MSP_MuaHangHoa_ThueTTDBGridView.KeyboardCommandProvider).TabKeyPress += new EventHandler(OnTabKeyPress);
            }
        }

        #endregion
       

        #region Event Handle
        private void LayoutRoot_KeyUp(object sender, KeyEventArgs e)
        {
            if (Keyboard.Modifiers == ModifierKeys.Control)
            {
                MSP_MuaHangHoa_ViewModel vm = GetViewModel();
                if (e.Key == Key.S)
                {
                    if (vm.CanSave)
                    {
                        vm.Save(sender, new Csla.Xaml.ExecuteEventArgs());
                    }
                }
                else if (e.Key == Key.F6)
                {
                    AddItems();
                }
                else if (e.Key == Key.D1)
                {
                    this.MSP_MuaHangHoa_MuaHangHoaChiTietTab.IsSelected = true;
                }
                else if (e.Key == Key.D2)
                {
                    this.MSP_MuaHangHoa_ThueChiTietTab.IsSelected = true;
                }
                else if (e.Key == Key.D3)
                {
                    this.MSP_MuaHangHoa_ChiPhiMuaHangTab.IsSelected = true;
                }
                else if (e.Key == Key.D4)
                {
                    this.MSP_MuaHangHoa_TSThieuCXLTab.IsSelected = true;
                }
                else if (e.Key == Key.D5)
                {
                    this.MSP_MuaHangHoa_TSThuaCXLTab.IsSelected = true;
                }
                else if (e.Key == Key.D6)
                {
                    this.MSP_MuaHangHoa_ThueNKTab.IsSelected = true;
                }
                else if (e.Key == Key.D7)
                {
                    this.MSP_MuaHangHoa_ThueTTDBTab.IsSelected = true;
                }
            }
            e.Handled = true;
        }

        

        void AddItemButton_Click(object sender, RoutedEventArgs e)
        {

            AddItems();
        }

        void DeleteItemButton_Click(object sender, RoutedEventArgs e)
        {
            DeleteItems();
          
        }

        public void AddItems()
        {
            if (this.MSP_MuaHangHoa_MuaHangHoaChiTietTab.IsSelected)
            {
                AddMuaHangHoaDetailsItem();
            }
        }
        private RadGridView GetActiveGridView()
        {
            if (this.MSP_MuaHangHoa_MuaHangHoaChiTietTab.IsSelected)
            {
                return MSP_MuaHangHoa_MuaHangHoaChiTietGridView;
            }
            else if (this.MSP_MuaHangHoa_ThueChiTietTab.IsSelected)
            {
                return MSP_MuaHangHoa_ThueChiTietGridView;
            }
            else if (this.MSP_MuaHangHoa_ChiPhiMuaHangTab.IsSelected)
            {
                return MSP_MuaHangHoa_ChiPhiMuaHangGridView;
            }
            else if (this.MSP_MuaHangHoa_TSThieuCXLTab.IsSelected)
            {
                return MSP_MuaHangHoa_TSThieuCXLGridView;
            }
            else if (this.MSP_MuaHangHoa_TSThuaCXLTab.IsSelected)
            {
                return MSP_MuaHangHoa_TSThuaCXLGridView;
            }
            else if (this.MSP_MuaHangHoa_ThueNKTab.IsSelected)
            {
                return MSP_MuaHangHoa_ThueNKGridView;
            }
            else if (this.MSP_MuaHangHoa_ThueTTDBTab.IsSelected)
            {
                return MSP_MuaHangHoa_ThueTTDBGridView;
            }
            
            return null;
        }

       

        void DeleteItems()
        {
            if (this.MSP_MuaHangHoa_ThueChiTietTab.IsSelected)
            {
                MSP_MuaHangHoa_ThueChild thueChild = (MSP_MuaHangHoa_ThueChild)(this.MSP_MuaHangHoa_ThueChiTietGridView.SelectedItem);
                IList<MSP_MuaHangHoa_ThueChild> list = GetViewModel().Model.MSP_MuaHangHoa_Thues;
                int index = 0;
                foreach (MSP_MuaHangHoa_ThueChild item in list)
                {
                    if (thueChild.GetHashCode() == item.GetHashCode())
                    {
                        break;
                    }
                    index++;
                }

                DeleteThueDetailsItem(index);
                
                
            }
            else if (this.MSP_MuaHangHoa_MuaHangHoaChiTietTab.IsSelected)
            {
                MSP_MuaHangHoa_ChiTietChild ChiTietChild = (MSP_MuaHangHoa_ChiTietChild)(this.MSP_MuaHangHoa_MuaHangHoaChiTietGridView.SelectedItem);
                IList<MSP_MuaHangHoa_ChiTietChild> list = GetViewModel().Model.MSP_MuaHangHoa_ChiTiets;
                int index = 0;
                foreach (MSP_MuaHangHoa_ChiTietChild item in list)
                {
                    if (ChiTietChild.GetHashCode() == item.GetHashCode())
                    {
                        break;
                    }
                    index++;
                }

                
                DeleteMuaHangDetailsItem(index);
            }
            else if (this.MSP_MuaHangHoa_ChiPhiMuaHangTab.IsSelected)
            {
                MSP_MuaHangHoa_ChiPhiMuaHangChild ChiPhiMuaHangChild = (MSP_MuaHangHoa_ChiPhiMuaHangChild)(this.MSP_MuaHangHoa_ChiPhiMuaHangGridView.SelectedItem);
                IList<MSP_MuaHangHoa_ChiPhiMuaHangChild> list = GetViewModel().Model.MSP_MuaHangHoa_ChiPhiMuaHangs;
                int index = 0;
                foreach (MSP_MuaHangHoa_ChiPhiMuaHangChild item in list)
                {
                    if (ChiPhiMuaHangChild.GetHashCode() == item.GetHashCode())
                    {
                        break;
                    }
                    index++;
                }

                
                DeleteChiPhiMuaHangDetailsItem(index);
                
            }
            else if (this.MSP_MuaHangHoa_TSThieuCXLTab.IsSelected)
            {
                MSP_MuaHangHoa_TSThieuCXLChild TSThieuCXLChild = (MSP_MuaHangHoa_TSThieuCXLChild)(this.MSP_MuaHangHoa_TSThieuCXLGridView.SelectedItem);
                IList<MSP_MuaHangHoa_TSThieuCXLChild> list = GetViewModel().Model.MSP_MuaHangHoa_TSThieuCXLs;
                int index = 0;
                foreach (MSP_MuaHangHoa_TSThieuCXLChild item in list)
                {
                    if (TSThieuCXLChild.GetHashCode() == item.GetHashCode())
                    {
                        break;
                    }
                    index++;
                }

                
                DeleteTSThieuCXLDetailsItem(index);
              
            }
            else if (this.MSP_MuaHangHoa_TSThuaCXLTab.IsSelected)
            {
                MSP_MuaHangHoa_TSThuaCXLChild TSThuaCXLChild = (MSP_MuaHangHoa_TSThuaCXLChild)(this.MSP_MuaHangHoa_TSThuaCXLGridView.SelectedItem);
                IList<MSP_MuaHangHoa_TSThuaCXLChild> list = GetViewModel().Model.MSP_MuaHangHoa_TSThuaCXLs;
                int index = 0;
                foreach (MSP_MuaHangHoa_TSThuaCXLChild item in list)
                {
                    if (TSThuaCXLChild.GetHashCode() == item.GetHashCode())
                    {
                        break;
                    }
                    index++;
                }

               
                DeleteTSThuaCXLDetailsItem(index);
                
            }
            else if (this.MSP_MuaHangHoa_ThueNKTab.IsSelected)
            {
                MSP_MuaHangHoa_ThueNKChild ThueNKChild = (MSP_MuaHangHoa_ThueNKChild)(this.MSP_MuaHangHoa_ThueNKGridView.SelectedItem);
                IList<MSP_MuaHangHoa_ThueNKChild> list = GetViewModel().Model.MSP_MuaHangHoa_ThueNKs;
                int index = 0;
                foreach (MSP_MuaHangHoa_ThueNKChild item in list)
                {
                    if (ThueNKChild.GetHashCode() == item.GetHashCode())
                    {
                        break;
                    }
                    index++;
                }

           
                DeleteThueNKDetailsItem(index);
                
            }
            else if (this.MSP_MuaHangHoa_ThueTTDBTab.IsSelected)
            {
                MSP_MuaHangHoa_ThueTTDBChild ThueTTDBChild = (MSP_MuaHangHoa_ThueTTDBChild)(this.MSP_MuaHangHoa_ThueTTDBGridView.SelectedItem);
                IList<MSP_MuaHangHoa_ThueTTDBChild> list = GetViewModel().Model.MSP_MuaHangHoa_ThueTTDBs;
                int index = 0;
                foreach (MSP_MuaHangHoa_ThueTTDBChild item in list)
                {
                    if (ThueTTDBChild.GetHashCode() == item.GetHashCode())
                    {
                        break;
                    }
                    index++;
                }

               
                DeleteThueTTDBDetailsItem(index);
                
            }

        }
        void GridView_AddingNewDataItem(object sender, GridViewAddingNewEventArgs e)
        {
            var grid = e.OwnerGridViewItemsControl;
            if (grid.Items.Count > 0)
            {
                GridViewUtil.FocusRow((RadGridView)grid, grid.Items.Count - 1);
                Dispatcher.BeginInvoke(new Action(() =>
                {
                    grid.CurrentCellInfo = new GridViewCellInfo(grid.Items[grid.Items.Count - 1], grid.Columns[0]);
                    grid.Focus();
                    grid.BeginEdit();
                    
                }));
            }
        }
              
        private void SaveAndNewButton_Click(object sender, RoutedEventArgs e)
        {
           MSP_MuaHangHoa_ViewModel vm = GetViewModel();
           vm.SaveAndNew();
        }

        private void MSP_MuaHangHoa_MoreInformation_PhanBoChiPhiButton_Click(object sender, RoutedEventArgs e)
        {
            PhanBoChiPhi_ChildWindow phanBoChiPhi = new PhanBoChiPhi_ChildWindow(this.GetViewModel());
            phanBoChiPhi.Show();
        }
        
        private void DatePicker_KeyUp(object sender, KeyEventArgs e)
        {
            List<Control> availableControl = new List<Control>();
            foreach (Control item in controls)
            {
                if (item.Visibility == System.Windows.Visibility.Visible)
                {
                    availableControl.Add(item);
                }
            }
            Control[] list = availableControl.ToArray();
            if (sender.GetHashCode() == list[availableControl.Count - 1].GetHashCode())
            {
                if (e.Key == Key.Enter)
                {
                    this.AddMuaHangHoaDetailsItem();
                }
            }
            else
            {
                ControlBehavior.DatePickerBehaviors.DatePicker_KeyUp(sender, e, controls);
            }
        }

        private void ComboBox_KeyUp(object sender, KeyEventArgs e)
        {
            List<Control> availableControl = new List<Control>();
            foreach (Control item in controls)
            {
                if (item.Visibility == System.Windows.Visibility.Visible)
                {
                    availableControl.Add(item);
                }
            }
            Control[] list = availableControl.ToArray();
            if (sender.GetHashCode() == list[availableControl.Count - 1].GetHashCode())
            {
                if (e.Key == Key.Enter)
                {
                    this.AddMuaHangHoaDetailsItem();
                }
            }
            else
            {
                ControlBehavior.ComboBoxBehaviors.ComboBox_KeyUp(sender, e, controls);
            }
        }

        private void Control_KeyUp(object sender, KeyEventArgs e)
        {
            List<Control> availableControl = new List<Control>();
            foreach (Control item in controls)
            {
                if (item.Visibility == System.Windows.Visibility.Visible)
                {
                    availableControl.Add(item);
                }
            }
            Control[] list = availableControl.ToArray();
            if (sender.GetHashCode() == list[availableControl.Count - 1].GetHashCode())
            {
                if (e.Key == Key.Enter)
                {
                    this.AddMuaHangHoaDetailsItem();
                }
            }
            else
            {
                ControlBehavior.ControlBehaviors.Control_KeyUp(sender, e, controls);
            }
        }
       

        private void BookedItemButton_Click(object sender, RoutedEventArgs e)
        {
            GetViewModel().GhiSo();
        }

        private void DeleteBookedItemButton_Click(object sender, RoutedEventArgs e)
        {
            GetViewModel().BoGhi();
        }

        private void LapPhieuChiItemButton_Click(object sender, RoutedEventArgs e)
        {

           if (this.GetViewModel().Model.Khoa != 0 && this.GetViewModel().Model.LoaiChungTuId != null)
            {
                System.Windows.Data.CollectionViewSource tm_PhieuChi_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["TM_PhieuChi_ViewModelSource"];
                TM_PhieuChi_ViewModel tm_PhieuChi_ViewModel = new TM_PhieuChi_ViewModel(this.GetViewModel().Model.Khoa, this.GetViewModel().Model.LoaiChungTuId);
                tm_PhieuChi_ViewModel.LoadCompleted += new EventHandler(PhieuChi_LoadCompleted);
                tm_PhieuChi_CollectionViewSource.Source = new List<object> { tm_PhieuChi_ViewModel };
            }
            else
            {
                MessageBoxResult result = MessageBox.Show("Không thể thực hiện chức năng này vi chứng từ không lưu được?", "Thông báo", MessageBoxButton.OK);
            }
        }
        
        private void PhieuChi_LoadCompleted(object sender, EventArgs e)
        {

            System.Windows.Data.CollectionViewSource tm_PhieuChi_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["TM_PhieuChi_ViewModelSource"];
            TM_PhieuChi_ViewModel tm_PhieuChi_ViewModel  = ((List<object>)tm_PhieuChi_CollectionViewSource.Source)[0] as TM_PhieuChi_ViewModel;

            if (tm_PhieuChi_ViewModel.Model.Khoa == 0)
            {
                FormNguoiNop formNguoiNop = new FormNguoiNop(this.GetViewModel(), NghiepVuType.MuaHangHoa);
                formNguoiNop.Show();
                this.LapPhieuChiItemButton.Content = "Xem phiếu chi";
            }
            else
            {
                    
                TM_PhieuChi_ChildWindow tm_PhieuChi_ChildWindow = new TM_PhieuChi_ChildWindow(tm_PhieuChi_ViewModel, this.GetViewModel(),NghiepVuType.MuaHangHoa);
                tm_PhieuChi_ChildWindow.Show();
                tm_PhieuChi_ChildWindow.Visibility = Visibility.Collapsed;
                MessageBoxResult result = MessageBox.Show("Phiếu chi đã tồn tại, bạn có muốn xem phiếu chi không ?", "Xem phiếu chi", MessageBoxButton.OKCancel);
                   
                if (result == MessageBoxResult.OK)
                {
                    tm_PhieuChi_ChildWindow.Visibility = Visibility.Visible;
                    tm_PhieuChi_ChildWindow.CountSave++;

                }
                else if (result == MessageBoxResult.Cancel)
                {
                    tm_PhieuChi_ChildWindow.Close();
                } 
            }
        }

        private void LapPhieuNhapItemButton_Click(object sender, RoutedEventArgs e)
        {
            if (this.GetViewModel().Model.Khoa != 0 && this.GetViewModel().Model.LoaiChungTuId != null)
            {
                System.Windows.Data.CollectionViewSource k_PhieuNhapKho_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["K_PhieuNhapKho_ViewModelSource"];
                K_PhieuNhapKho_ViewModel k_PhieuNhapKho_ViewModel = new K_PhieuNhapKho_ViewModel(this.GetViewModel().Model.Khoa, this.GetViewModel().Model.LoaiChungTuId);
                k_PhieuNhapKho_ViewModel.LoadCompleted += new EventHandler(PhieuNhap_LoadCompleted);
                k_PhieuNhapKho_CollectionViewSource.Source = new List<object> { k_PhieuNhapKho_ViewModel };
            }
            else
            {
                MessageBoxResult result = MessageBox.Show("Không thể thực hiện chức năng này vi chứng từ không lưu được?", "Thông báo", MessageBoxButton.OK);
            }
  
        }

        
        private void PhieuNhap_LoadCompleted(object sender, EventArgs e)
        {

            System.Windows.Data.CollectionViewSource k_PhieuNhapKho_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["K_PhieuNhapKho_ViewModelSource"];
            K_PhieuNhapKho_ViewModel k_PhieuNhapKho_ViewModel = ((List<object>)k_PhieuNhapKho_CollectionViewSource.Source)[0] as K_PhieuNhapKho_ViewModel;

            if (k_PhieuNhapKho_ViewModel.Model.Khoa == 0)
            {
                FormNguoiGiao formNguoiGiao = new FormNguoiGiao(this.GetViewModel(), NghiepVuType.MuaHangHoa);
                formNguoiGiao.Show();
                this.LapPhieuNhapItemButton.Content = "Xem phiếu nhập";
            }
            else
            {

                K_PhieuNhapKho_ChildWindow k_PhieuNhapKho_ChildWindow = new K_PhieuNhapKho_ChildWindow(k_PhieuNhapKho_ViewModel, this.GetViewModel(), NghiepVuType.MuaHangHoa);
                k_PhieuNhapKho_ChildWindow.Show();
                k_PhieuNhapKho_ChildWindow.Visibility = Visibility.Collapsed;
                MessageBoxResult result = MessageBox.Show("Phiếu nhập đã tồn tại, bạn có muốn xem phiếu nhập không ?", "Xem phiếu nhập", MessageBoxButton.OKCancel);

                if (result == MessageBoxResult.OK)
                {
                    k_PhieuNhapKho_ChildWindow.Visibility = Visibility.Visible;
                    k_PhieuNhapKho_ChildWindow.CountSave++;

                }
                else if (result == MessageBoxResult.Cancel)
                {
                    k_PhieuNhapKho_ChildWindow.Close();
                }
            }
        }

        void OnTabKeyPress(object sender, EventArgs e)
        {
            this.tabControl.SelectedItem = tabControl.Items[0];
            this.AddMuaHangHoaDetailsItem();
        }

        void OnReachLastColumn(object sender, ReachLastColumnArgs e)
        {

            List<TabItem> AvailableTabItem = new List<TabItem>();
            int indexCurrentTab = 0;
            foreach (TabItem item in this.tabControl.Items)
            {
                if (item.Visibility == System.Windows.Visibility.Visible)
                {
                    AvailableTabItem.Add(item);
                    if (item.GetHashCode() == tabControl.SelectedItem.GetHashCode())
                    {
                        indexCurrentTab = AvailableTabItem.IndexOf(item);
                    }

                }
            }


            TabItem[] list = AvailableTabItem.ToArray();
            if (indexCurrentTab == (AvailableTabItem.Count - 1))
            {
                this.tabControl.SelectedItem = list[0];
                FocusAfterChangeTab(this.MSP_MuaHangHoa_MuaHangHoaChiTietGridView, e.Index);
                
                
            }
            else
            {
                this.tabControl.SelectedItem = list[indexCurrentTab + 1];
                if (list[indexCurrentTab + 1].Name.Equals("MSP_MuaHangHoa_ChiPhiMuaHangTab"))
                {
                    FocusAfterChangeTab(this.MSP_MuaHangHoa_ChiPhiMuaHangGridView, e.Index);
                }
                else if (list[indexCurrentTab + 1].Name.Equals("MSP_MuaHangHoa_ThueChiTietTab"))
                {
                    FocusAfterChangeTab(this.MSP_MuaHangHoa_ThueChiTietGridView, e.Index);

                }
                else if (list[indexCurrentTab + 1].Name.Equals("MSP_MuaHangHoa_ThueNKTab"))
                {
                    FocusAfterChangeTab(this.MSP_MuaHangHoa_ThueNKGridView, e.Index);

                }
                else if (list[indexCurrentTab + 1].Name.Equals("MSP_MuaHangHoa_ThueTTDBTab"))
                {
                    FocusAfterChangeTab(this.MSP_MuaHangHoa_ThueTTDBGridView, e.Index);

                }
                else if (list[indexCurrentTab + 1].Name.Equals("MSP_MuaHangHoa_TSThieuCXLTab"))
                {
                    FocusAfterChangeTab(this.MSP_MuaHangHoa_TSThieuCXLGridView, e.Index);

                }
                else if (list[indexCurrentTab + 1].Name.Equals("MSP_MuaHangHoa_TSThuaCXLTab"))
                {
                    FocusAfterChangeTab(this.MSP_MuaHangHoa_TSThuaCXLGridView, e.Index);

                }
            }

        }

        private void FocusAfterChangeTab(GridViewDataControl grid, int index)
        {
          
            Dispatcher.BeginInvoke(new Action(() =>
            {
                grid.CurrentCellInfo = new GridViewCellInfo(grid.Items[index], grid.Columns[0]);
                grid.Focus();
                grid.BeginEdit();
            }));
           
        }
        private void MSP_MuaHangHoa_GeneralInformation_NhaCungCapId_AddItemButton_Click(object sender, RoutedEventArgs e)
        {
            DM_NhaCungCap_ChildWindow dm_NhaCungCap_ChildWindow = new DM_NhaCungCap_ChildWindow();
            dm_NhaCungCap_ChildWindow.Show();
            dm_NhaCungCap_ChildWindow.SaveClicked += new EventHandler(dm_NhaCungCap_ViewModel_Saved);
        }

        private void MSP_MuaHangHoa_MoreInformation_PhuongThucThanhToanId_AddItemButton_Click(object sender, RoutedEventArgs e)
        {
            DM_PhuongThucThanhToan_ChildWindow dm_PhuongThucThanhToan_ChildWindow = new DM_PhuongThucThanhToan_ChildWindow();
            dm_PhuongThucThanhToan_ChildWindow.Show();
            dm_PhuongThucThanhToan_ChildWindow.SaveClicked += new EventHandler(dm_PhuongThucThanhToan_ViewModel_Saved);
        }

        private void MSP_MuaHangHoa_MoreInformation_LoaiTienId_AddItemButton_Click(object sender, RoutedEventArgs e)
        {
            DM_LoaiTienTe_ChildWindow dm_LoaiTienTe_ChildWindow = new DM_LoaiTienTe_ChildWindow();
            dm_LoaiTienTe_ChildWindow.Show();
            dm_LoaiTienTe_ChildWindow.SaveClicked += new EventHandler(dm_LoaiTienTe_ViewModel_Saved);
        }

        private void MSP_MuaHangHoa_MoreInformation_LoaiMuaSanPhamId_AddItemButton_Click(object sender, RoutedEventArgs e)
        {
            DM_LoaiMuaSanPham_ChildWindow dm_LoaiMuaSanPham_ChildWindow = new DM_LoaiMuaSanPham_ChildWindow();
            dm_LoaiMuaSanPham_ChildWindow.Show();
            dm_LoaiMuaSanPham_ChildWindow.SaveClicked += new EventHandler(dm_LoaiMuaSanPham_ViewModel_Saved);
        }
       
        #endregion

        #region View Model Related Methods
        private MSP_MuaHangHoa_ViewModel GetViewModel()
        {
            System.Windows.Data.CollectionViewSource msp_MuaHangHoa_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["MSP_MuaHangHoa_ViewModelSource"];
            return ((List<object>)msp_MuaHangHoa_CollectionViewSource.Source)[0] as MSP_MuaHangHoa_ViewModel;
        }



        private void OnMuaHangHoaLoadCompleteted(object sender, EventArgs e)
        {
            if (this.GetViewModel().Model.DaThanhToan == true && this.GetViewModel().Model.Khoa != 0)
            {
                this.LapPhieuChiItemButton.IsEnabled = true;
               
            }
            else
            {
                this.LapPhieuChiItemButton.IsEnabled = false;
                
            }

            if (this.GetViewModel().Model.Khoa != 0)
            {
                this.LapPhieuNhapItemButton.IsEnabled = true;
            }
            else
            {
                this.LapPhieuNhapItemButton.IsEnabled = false;
            }

        }
        void dm_NhaCungCap_ViewModel_Saved(object sender, EventArgs e)
        {
            System.Windows.Data.CollectionViewSource dm_NhaCungCap_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_NhaCungCap_ListViewModelSource"];
            DM_NhaCungCap_ListViewModel vm = ((List<object>)dm_NhaCungCap_ListViewSource.Source)[0] as DM_NhaCungCap_ListViewModel;
            vm.GetDM_NhaCungCap_ListViewModel(BusinessConfiguration.Configuration.ComboboxFetchMode, BusinessConfiguration.Configuration.DieuKienLocNCC_NhaCungCap);
        }

        void dm_LoaiTienTe_ViewModel_Saved(object sender, EventArgs e)
        {
            System.Windows.Data.CollectionViewSource dm_LoaiTienTe_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_LoaiTienTe_ListViewModelSource"];
            DM_LoaiTienTe_ListViewModel vm = ((List<object>)dm_LoaiTienTe_ListViewSource.Source)[0] as DM_LoaiTienTe_ListViewModel;
            vm.GetDM_LoaiTienTe_ListViewModel(BusinessConfiguration.Configuration.ComboboxFetchMode);
        }

        void dm_LoaiMuaSanPham_ViewModel_Saved(object sender, EventArgs e)
        {
            System.Windows.Data.CollectionViewSource dm_LoaiMuaSanPham_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_LoaiMuaSanPham_ListViewModelSource"];
            DM_LoaiMuaSanPham_ListViewModel vm = ((List<object>)dm_LoaiMuaSanPham_ListViewSource.Source)[0] as DM_LoaiMuaSanPham_ListViewModel;
            vm.GetDM_LoaiMuaSanPham_ListViewModel(BusinessConfiguration.Configuration.ComboboxFetchMode);
        }

        void dm_PhuongThucThanhToan_ViewModel_Saved(object sender, EventArgs e)
        {
            System.Windows.Data.CollectionViewSource dm_PhuongThucThanhToan_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_PhuongThucThanhToan_ListViewModelSource"];
            DM_PhuongThucThanhToan_ListViewModel vm = ((List<object>)dm_PhuongThucThanhToan_ListViewSource.Source)[0] as DM_PhuongThucThanhToan_ListViewModel;
            vm.GetDM_PhuongThucThanhToan_ListViewModel(BusinessConfiguration.Configuration.ComboboxFetchMode);
        }

        public void DoFilterOnDefaultDM_SanPham()
        {
           
                System.Windows.Data.CollectionViewSource dm_HangHoa_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_HangHoa_ListViewModelSource"];
                DM_HangHoa_ListViewModel dm_HangHoa_ListViewModel = new DM_HangHoa_ListViewModel(BusinessConfiguration.Configuration.ComboboxFetchMode);
                dm_HangHoa_CollectionViewSource.Source = new List<object> { dm_HangHoa_ListViewModel };
           
        }
        void msp_MuaHangHoa_EnableButtonLapPhieu(object sender, EventArgs e)
        {
            if (this.GetViewModel().Model.Khoa != 0 && this.GetViewModel().Model.DaThanhToan == true)
            {
                this.LapPhieuChiItemButton.IsEnabled = true;
                this.LapPhieuNhapItemButton.IsEnabled = true;
            }
            else if (this.GetViewModel().Model.Khoa != 0)
            {
                this.LapPhieuNhapItemButton.IsEnabled = true;
                this.LapPhieuChiItemButton.IsEnabled = false;
            }
            else
            {
                this.LapPhieuChiItemButton.IsEnabled = false;
                this.LapPhieuNhapItemButton.IsEnabled = false;
            }

        }
        void msp_MuaHangHoa_TKCoChanged(object sender, TKCoIdChangedEventArgs e)
        {
            if (this.GetViewModel().Model.LoaiMuaSanPhamId == 3)
            {
                MSP_MuaHangHoa_ChiTietChild ChiTietChild = GetViewModel().Model.MSP_MuaHangHoa_ChiTiets[e.Index];
                MSP_MuaHangHoa_ThueChild ThueChild = GetViewModel().Model.MSP_MuaHangHoa_Thues[e.Index];
                ThueChild.TKCoId = ChiTietChild.TKCoId;
                
            }
            else if (this.GetViewModel().Model.LoaiHoaDonId == 1 || this.GetViewModel().Model.LoaiHoaDonId == null)
            {

                MSP_MuaHangHoa_ChiTietChild ChiTietChild = GetViewModel().Model.MSP_MuaHangHoa_ChiTiets[e.Index];
                MSP_MuaHangHoa_ThueChild ThueChild = GetViewModel().Model.MSP_MuaHangHoa_Thues[e.Index];
                ThueChild.TKCoId = ChiTietChild.TKCoId;     
            }

        }

        void msp_MuaHangHoa_ThueSuatIdChanged(object sender, ThueSuatIdChangedEventArgs e)
        {
            
            System.Windows.Data.CollectionViewSource dm_ThueSuat_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_ThueSuat_ListViewModelSource"];
            DM_ThueSuat_ListViewModel dm_ThueSuat_ListViewModel = ((List<object>)dm_ThueSuat_CollectionViewSource.Source)[0] as DM_ThueSuat_ListViewModel;    
            
            MSP_MuaHangHoa_ThueChild ThueChild = GetViewModel().Model.MSP_MuaHangHoa_Thues[e.Index];
            IList<DM_ThueSuatInfo> list = dm_ThueSuat_ListViewModel.Model.getListOfInfo();
            foreach (DM_ThueSuatInfo item in list)
            {
                if (item.Khoa == e.ThueSuatId)
                {
                    ThueChild.ThueSuatValue = item.GiaTriTinhThue;
                }
            }

           

        }
        void msp_MuaHangHoa_TinhChatHangHoaChanged(object sender, EventArgs e)
        {
            int? tinhChatHangHoaId = this.GetViewModel().Model.TinhChatHangHoaId;
            
            System.Windows.Data.CollectionViewSource dm_HangHoa_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_HangHoa_ListViewModelSource"];
            DM_HangHoa_ListViewModel dm_HangHoa_ListViewModel = ((List<object>)dm_HangHoa_CollectionViewSource.Source)[0] as DM_HangHoa_ListViewModel;
            dm_HangHoa_ListViewModel.GetDM_HangHoa((int)tinhChatHangHoaId);
              
           
        }

        void msp_MuaHangHoa_LoaiTienTeChanged(object sender, EventArgs e)
        {
            
            System.Windows.Data.CollectionViewSource dm_LoaiTienTe_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_LoaiTienTe_ListViewModelSource"];
            DM_LoaiTienTe_ListViewModel dm_LoaiTienTe_ListViewModel = ((List<object>)dm_LoaiTienTe_CollectionViewSource.Source)[0] as DM_LoaiTienTe_ListViewModel;
            IList<DM_LoaiTienTeInfo> list = dm_LoaiTienTe_ListViewModel.Model.getListOfInfo();
            foreach( DM_LoaiTienTeInfo item in list)
            {
                if (item.Khoa == GetViewModel().Model.LoaiTienId)
                {
                    GetViewModel().Model.TyGia = item.TyGiaQuyDoi;
                    break;
                }
            }
        }
       
        
        void msp_MuaHangHoa_HangHoaIdChanged(object sender, HangHoaIdChangedEventArgs e)
        {
            
            MSP_MuaHangHoa_ChiTietChild ChiTietChild =  GetViewModel().Model.MSP_MuaHangHoa_ChiTiets[e.Index];
            MSP_MuaHangHoa_ThueChild ThueChild =  GetViewModel().Model.MSP_MuaHangHoa_Thues[e.Index];
            MSP_MuaHangHoa_ChiPhiMuaHangChild ChiPhiMuaHangChild =  GetViewModel().Model.MSP_MuaHangHoa_ChiPhiMuaHangs[e.Index];
            MSP_MuaHangHoa_TSThuaCXLChild TSThuaCXLChild =  GetViewModel().Model.MSP_MuaHangHoa_TSThuaCXLs[e.Index];
            MSP_MuaHangHoa_TSThieuCXLChild TSThieuCXLChild = GetViewModel().Model.MSP_MuaHangHoa_TSThieuCXLs[e.Index];
            MSP_MuaHangHoa_ThueNKChild ThueNKChild = GetViewModel().Model.MSP_MuaHangHoa_ThueNKs[e.Index];
            MSP_MuaHangHoa_ThueTTDBChild ThueTTDBChild = GetViewModel().Model.MSP_MuaHangHoa_ThueTTDBs[e.Index];

            System.Windows.Data.CollectionViewSource dm_HangHoa_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_HangHoa_ListViewModelSource"];
            DM_HangHoa_ListViewModel dm_HangHoa_ListViewModel = ((List<object>)dm_HangHoa_CollectionViewSource.Source)[0] as DM_HangHoa_ListViewModel;
            System.Collections.Generic.IList<DM_HangHoaInfo> list = dm_HangHoa_ListViewModel.Model.getListOfInfo();

            System.Windows.Data.CollectionViewSource dm_TKNo_ChiTiet_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_ChiTiet_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel dm_TKNo_ChiTiet_ListViewModel = ((List<object>)dm_TKNo_ChiTiet_CollectionViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            System.Collections.Generic.IList<DM_TaiKhoanInfo> listTKNo_ChiTiet = dm_TKNo_ChiTiet_ListViewModel.Model.getListOfInfo();

            System.Windows.Data.CollectionViewSource dm_TKCo_ChiTiet_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_ChiTiet_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel dm_TKCo_ChiTiet_ListViewModel = ((List<object>)dm_TKCo_ChiTiet_CollectionViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            System.Collections.Generic.IList<DM_TaiKhoanInfo> listTKCo_ChiTiet = dm_TKCo_ChiTiet_ListViewModel.Model.getListOfInfo();

            System.Windows.Data.CollectionViewSource dm_TKNo_ChiPhiMuaHang_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_ChiPhiMuaHang_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel dm_TKNo_ChiPhiMuaHang_ListViewModel = ((List<object>)dm_TKNo_ChiPhiMuaHang_CollectionViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            System.Collections.Generic.IList<DM_TaiKhoanInfo> listTKNo_ChiPhiMuaHang = dm_TKNo_ChiPhiMuaHang_ListViewModel.Model.getListOfInfo();

            System.Windows.Data.CollectionViewSource dm_TKCo_ChiPhiMuaHang_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_ChiPhiMuaHang_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel dm_TKCo_ChiPhiMuaHang_ListViewModel = ((List<object>)dm_TKCo_ChiPhiMuaHang_CollectionViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            System.Collections.Generic.IList<DM_TaiKhoanInfo> listTKCo_ChiPhiMuaHang = dm_TKCo_ChiPhiMuaHang_ListViewModel.Model.getListOfInfo();

            System.Windows.Data.CollectionViewSource dm_TKNo_Thue_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_Thue_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel dm_TKNo_Thue_ListViewModel = ((List<object>)dm_TKNo_Thue_CollectionViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            System.Collections.Generic.IList<DM_TaiKhoanInfo> listTKNo_Thue = dm_TKNo_Thue_ListViewModel.Model.getListOfInfo();

            System.Windows.Data.CollectionViewSource dm_TKCo_TSThieuCXL_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_TSThieuCXL_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel dm_TKCo_TSThieuCXL_ListViewModel = ((List<object>)dm_TKCo_TSThieuCXL_CollectionViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            System.Collections.Generic.IList<DM_TaiKhoanInfo> listTKCo_TSThieuCXL = dm_TKCo_TSThieuCXL_ListViewModel.Model.getListOfInfo();

            System.Windows.Data.CollectionViewSource dm_TKNo_TSThieuCXL_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_TSThieuCXL_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel dm_TKNo_TSThieuCXL_ListViewModel = ((List<object>)dm_TKNo_TSThieuCXL_CollectionViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            System.Collections.Generic.IList<DM_TaiKhoanInfo> listTKNo_TSThieuCXL = dm_TKNo_TSThieuCXL_ListViewModel.Model.getListOfInfo();

            System.Windows.Data.CollectionViewSource dm_TKCo_TSThuaCXL_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_TSThuaCXL_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel dm_TKCo_TSThuaCXL_ListViewModel = ((List<object>)dm_TKCo_TSThuaCXL_CollectionViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            System.Collections.Generic.IList<DM_TaiKhoanInfo> listTKCo_TSThuaCXL = dm_TKCo_TSThuaCXL_ListViewModel.Model.getListOfInfo();

            System.Windows.Data.CollectionViewSource dm_TKNo_TSThuaCXL_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_TSThuaCXL_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel dm_TKNo_TSThuaCXL_ListViewModel = ((List<object>)dm_TKNo_TSThuaCXL_CollectionViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            System.Collections.Generic.IList<DM_TaiKhoanInfo> listTKNo_TSThuaCXL = dm_TKNo_TSThuaCXL_ListViewModel.Model.getListOfInfo();

            System.Windows.Data.CollectionViewSource dm_TKNo_ThueNK_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_ThueNK_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel dm_TKNo_ThueNK_ListViewModel = ((List<object>)dm_TKNo_ThueNK_CollectionViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            System.Collections.Generic.IList<DM_TaiKhoanInfo> listTKNo_ThueNK = dm_TKNo_ThueNK_ListViewModel.Model.getListOfInfo();

            System.Windows.Data.CollectionViewSource dm_TKCo_ThueNK_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_ThueNK_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel dm_TKCo_ThueNK_ListViewModel = ((List<object>)dm_TKCo_ThueNK_CollectionViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            System.Collections.Generic.IList<DM_TaiKhoanInfo> listTKCo_ThueNK = dm_TKCo_ThueNK_ListViewModel.Model.getListOfInfo();

            System.Windows.Data.CollectionViewSource dm_TKNo_ThueTTDB_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_ThueTTDB_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel dm_TKNo_ThueTTDB_ListViewModel = ((List<object>)dm_TKNo_ThueTTDB_CollectionViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            System.Collections.Generic.IList<DM_TaiKhoanInfo> listTKNo_ThueTTDB = dm_TKNo_ThueTTDB_ListViewModel.Model.getListOfInfo();

            System.Windows.Data.CollectionViewSource dm_TKCo_ThueTTDB_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_ThueTTDB_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel dm_TKCo_ThueTTDB_ListViewModel = ((List<object>)dm_TKCo_ThueTTDB_CollectionViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            System.Collections.Generic.IList<DM_TaiKhoanInfo> listTKCo_ThueTTDB = dm_TKCo_ThueTTDB_ListViewModel.Model.getListOfInfo();

           

               
                
            foreach (DM_HangHoaInfo item in list)
            {
                if (item.Khoa == e.HangHoaId)
                {
                    ChiTietChild.DienGiai = item.TenViet;
                    ChiTietChild.KhoId = item.KhoNgamDinhId;
                    ChiTietChild.TKKhoId = (int)item.TKKhoId;
                    ChiTietChild.DonGia = item.DonGiaBan;
                    ChiTietChild.TKNoId = (int)item.TKKhoId;
                    ChiTietChild.TKCoId = listTKCo_ChiTiet[0].Khoa;
                    ChiTietChild.DVTId = item.DonViTinhId;

                    ThueChild.HangHoaId = item.Khoa;
                    ThueChild.DienGiai = item.TenViet;
                    ThueChild.LoaiHoaDonId = this.GetViewModel().Model.LoaiHoaDonId;
                    ThueChild.ThueSuatId = item.ThueSuatId;
                    ThueChild.TKNoId = listTKNo_Thue[0].Khoa;
                    ThueChild.TKCoId = ChiTietChild.TKCoId;
                    

                    ThueNKChild.HangHoaId = item.Khoa;
                    ThueNKChild.DienGiai = item.TenViet;
                    ThueNKChild.TkNoId = listTKNo_ThueNK[0].Khoa;
                    ThueNKChild.TkCoId = listTKCo_ThueNK[0].Khoa;

                    
                        
                    TSThuaCXLChild.HangHoaId = item.Khoa;
                    TSThuaCXLChild.DienGiai = item.TenViet;
                    TSThuaCXLChild.TkNoId = listTKNo_TSThuaCXL[0].Khoa;
                    TSThuaCXLChild.TkCoId = listTKCo_TSThuaCXL[0].Khoa;

                    TSThieuCXLChild.HangHoaId = item.Khoa;
                    TSThieuCXLChild.DienGiai = item.TenViet;
                    TSThieuCXLChild.TkNoId = listTKNo_TSThieuCXL[0].Khoa;
                    TSThieuCXLChild.TkCoId = listTKCo_TSThieuCXL[0].Khoa;


                    ChiPhiMuaHangChild.HangHoaId = item.Khoa;
                    ChiPhiMuaHangChild.DienGiai = item.TenViet;
                    ChiPhiMuaHangChild.TkNoId = listTKNo_ChiPhiMuaHang[0].Khoa;
                    ChiPhiMuaHangChild.TkCoId = listTKCo_ChiPhiMuaHang[0].Khoa;

                    ThueTTDBChild.HangHoaId = item.Khoa;
                    ThueTTDBChild.DienGiai = item.TenViet;
                    ThueTTDBChild.TkNoId = listTKNo_ThueTTDB[0].Khoa;
                    ThueTTDBChild.TkCoId = listTKCo_ThueTTDB[0].Khoa;

                  
                    break;
                }
            }

           

        }

        void msp_MuaHangHoa_StateChanged(object sender, DieuKienNghiepVuEventArgs e)
        {
            int dknv = 1;         
            if (dknv == 1 || dknv == 2)
            {
                DoFilterDKNV1And2();         

            }
            else if (dknv == 3 || dknv == 4)
            {
                DoFilterDKNV3And4();
       
            }
            else if (dknv == 5)
            {
                DoFilterDKNV5();   
       
            }
            else if (dknv == 6)
            {
                DoFilterDKNV6();  

            }
            else if (dknv == 7)
            {
                DoFilterDKNV7();

            }
            else if (dknv == 8)
            {
                DoFilterDKNV8();
            }
            
        }

        public void DoFilterOnDefaultDKNV1()
        {

          
            List<string> taiKhoanNoChiTiet = new List<string>();
            taiKhoanNoChiTiet.Add("151");
            taiKhoanNoChiTiet.Add("1521");
            taiKhoanNoChiTiet.Add("1531");
            taiKhoanNoChiTiet.Add("1561");
            taiKhoanNoChiTiet.Add("1567");
            taiKhoanNoChiTiet.Add("158");
            taiKhoanNoChiTiet.Add("611");

            List<string> taiKhoanCoChiTiet = new List<string>();
            taiKhoanCoChiTiet.Add("331");

            System.Windows.Data.CollectionViewSource dm_TaiKhoanNo_ChiTiet_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_ChiTiet_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel dm_TaiKhoanNo_ChiTiet_ListViewModel = new DM_TaiKhoan_ListViewModel(BusinessConfiguration.Configuration.ComboBoxFilterMode);
            dm_TaiKhoanNo_ChiTiet_ListViewModel.filterDKNV(taiKhoanNoChiTiet);
            dm_TaiKhoanNo_ChiTiet_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanNoChiTietChanged);
            dm_TaiKhoanNo_ChiTiet_CollectionViewSource.Source = new List<object> { dm_TaiKhoanNo_ChiTiet_ListViewModel };

            System.Windows.Data.CollectionViewSource dm_TaiKhoanCo_ChiTiet_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_ChiTiet_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel dm_TaiKhoanCo_ChiTiet_ListViewModel = new DM_TaiKhoan_ListViewModel(BusinessConfiguration.Configuration.ComboBoxFilterMode);
            dm_TaiKhoanCo_ChiTiet_ListViewModel.filterDKNV(taiKhoanCoChiTiet);
            dm_TaiKhoanCo_ChiTiet_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanCoChiTietChanged);
            dm_TaiKhoanCo_ChiTiet_CollectionViewSource.Source = new List<object> { dm_TaiKhoanCo_ChiTiet_ListViewModel };


            List<string> taiKhoanNoThue = new List<string>();
            taiKhoanNoThue.Add("1331");

            List<string> taiKhoanCoThue = new List<string>();
            taiKhoanCoThue.Add("331");


            System.Windows.Data.CollectionViewSource dm_TaiKhoanNo_Thue_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_Thue_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel dm_TaiKhoanNo_Thue_ListViewModel = new DM_TaiKhoan_ListViewModel(BusinessConfiguration.Configuration.ComboBoxFilterMode);
            dm_TaiKhoanNo_Thue_ListViewModel.filterDKNV(taiKhoanNoThue);
            dm_TaiKhoanNo_Thue_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanNoThueChanged);
            dm_TaiKhoanNo_Thue_CollectionViewSource.Source = new List<object> { dm_TaiKhoanNo_Thue_ListViewModel };

            System.Windows.Data.CollectionViewSource dm_TaiKhoanCo_Thue_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_Thue_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel dm_TaiKhoanCo_Thue_ListViewModel = new DM_TaiKhoan_ListViewModel(BusinessConfiguration.Configuration.ComboBoxFilterMode);
            dm_TaiKhoanCo_Thue_ListViewModel.filterDKNV(taiKhoanCoThue);
            dm_TaiKhoanCo_Thue_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanCoThueChanged);
            dm_TaiKhoanCo_Thue_CollectionViewSource.Source = new List<object> { dm_TaiKhoanCo_Thue_ListViewModel };

            List<string> taiKhoanNoChiPhiMuaHang = new List<string>();
            taiKhoanNoChiPhiMuaHang.Add("151");
            taiKhoanNoChiPhiMuaHang.Add("1521");
            taiKhoanNoChiPhiMuaHang.Add("1531");
            taiKhoanNoChiPhiMuaHang.Add("1561");
            taiKhoanNoChiPhiMuaHang.Add("1567");
            taiKhoanNoChiPhiMuaHang.Add("158");
            taiKhoanNoChiPhiMuaHang.Add("611");

            List<string> taiKhoanCoChiPhiMuaHang = new List<string>();
            taiKhoanCoChiPhiMuaHang.Add("1522");
            taiKhoanCoChiPhiMuaHang.Add("1532");
            taiKhoanCoChiPhiMuaHang.Add("1562");

           

            System.Windows.Data.CollectionViewSource dm_TaiKhoanNo_ChiPhiMuaHang_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_ChiPhiMuaHang_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel dm_TaiKhoanNo_ChiPhiMuaHang_ListViewModel = new DM_TaiKhoan_ListViewModel(BusinessConfiguration.Configuration.ComboBoxFilterMode);
            dm_TaiKhoanNo_ChiPhiMuaHang_ListViewModel.filterDKNV(taiKhoanNoChiPhiMuaHang);
            dm_TaiKhoanNo_ChiPhiMuaHang_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanNoChiPhiMuaHangChanged);
            dm_TaiKhoanNo_ChiPhiMuaHang_CollectionViewSource.Source = new List<object> { dm_TaiKhoanNo_ChiPhiMuaHang_ListViewModel };

            System.Windows.Data.CollectionViewSource dm_TaiKhoanCo_ChiPhiMuaHang_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_ChiPhiMuaHang_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel dm_TaiKhoanCo_ChiPhiMuaHang_ListViewModel = new DM_TaiKhoan_ListViewModel(BusinessConfiguration.Configuration.ComboBoxFilterMode);
            dm_TaiKhoanCo_ChiPhiMuaHang_ListViewModel.filterDKNV(taiKhoanCoChiPhiMuaHang);
            dm_TaiKhoanCo_ChiPhiMuaHang_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanCoChiPhiMuaHangChanged);
            dm_TaiKhoanCo_ChiPhiMuaHang_CollectionViewSource.Source = new List<object> { dm_TaiKhoanCo_ChiPhiMuaHang_ListViewModel };

            List<string> taiKhoanNoTSThieuCXL = new List<string>();
            taiKhoanNoTSThieuCXL.Add("1381");

            List<string> taiKhoanCoTSThieuCXL = new List<string>();
            taiKhoanCoTSThieuCXL.Add("331");


            System.Windows.Data.CollectionViewSource dm_TaiKhoanNo_TSThieuCXL_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_TSThieuCXL_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel dm_TaiKhoanNo_TSThieuCXL_ListViewModel = new DM_TaiKhoan_ListViewModel(BusinessConfiguration.Configuration.ComboBoxFilterMode);
            dm_TaiKhoanNo_TSThieuCXL_ListViewModel.filterDKNV(taiKhoanNoTSThieuCXL);
            dm_TaiKhoanNo_TSThieuCXL_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanNoTSThieuCXLChanged);
            dm_TaiKhoanNo_TSThieuCXL_CollectionViewSource.Source = new List<object> { dm_TaiKhoanNo_TSThieuCXL_ListViewModel };

            System.Windows.Data.CollectionViewSource dm_TaiKhoanCo_TSThieuCXL_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_TSThieuCXL_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel dm_TaiKhoanCo_TSThieuCXL_ListViewModel = new DM_TaiKhoan_ListViewModel(BusinessConfiguration.Configuration.ComboBoxFilterMode);
            dm_TaiKhoanCo_TSThieuCXL_ListViewModel.filterDKNV(taiKhoanCoTSThieuCXL);
            dm_TaiKhoanCo_TSThieuCXL_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanCoTSThieuCXLChanged);
            dm_TaiKhoanCo_TSThieuCXL_CollectionViewSource.Source = new List<object> { dm_TaiKhoanCo_TSThieuCXL_ListViewModel };


            List<string> taiKhoanNoTSThuaCXL = new List<string>();
            taiKhoanNoTSThuaCXL.Add("1521");
            taiKhoanNoTSThuaCXL.Add("1531");
            taiKhoanNoTSThuaCXL.Add("1561");
            taiKhoanNoTSThuaCXL.Add("1567");
            taiKhoanNoTSThuaCXL.Add("158");
            taiKhoanNoTSThuaCXL.Add("611");

            List<string> taiKhoanCoTSThuaCXL = new List<string>();
            taiKhoanCoTSThuaCXL.Add("3381");

            System.Windows.Data.CollectionViewSource dm_TaiKhoanNo_TSThuaCXL_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_TSThuaCXL_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel dm_TaiKhoanNo_TSThuaCXL_ListViewModel = new DM_TaiKhoan_ListViewModel(BusinessConfiguration.Configuration.ComboBoxFilterMode);
            dm_TaiKhoanNo_TSThuaCXL_ListViewModel.filterDKNV(taiKhoanNoTSThuaCXL);
            dm_TaiKhoanNo_TSThuaCXL_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanNoTSThuaCXLChanged);
            dm_TaiKhoanNo_TSThuaCXL_CollectionViewSource.Source = new List<object> { dm_TaiKhoanNo_TSThuaCXL_ListViewModel };

            System.Windows.Data.CollectionViewSource dm_TaiKhoanCo_TSThuaCXL_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_TSThuaCXL_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel dm_TaiKhoanCo_TSThuaCXL_ListViewModel = new DM_TaiKhoan_ListViewModel(BusinessConfiguration.Configuration.ComboBoxFilterMode);
            dm_TaiKhoanCo_TSThuaCXL_ListViewModel.filterDKNV(taiKhoanCoTSThuaCXL);
            dm_TaiKhoanCo_TSThuaCXL_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanCoTSThuaCXLChanged);
            dm_TaiKhoanCo_TSThuaCXL_CollectionViewSource.Source = new List<object> { dm_TaiKhoanCo_TSThuaCXL_ListViewModel };

            System.Windows.Data.CollectionViewSource dm_TaiKhoanCo_ThueNK_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_ThueNK_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel dm_TaiKhoanCo_ThueNK_ListViewModel = new DM_TaiKhoan_ListViewModel(BusinessConfiguration.Configuration.ComboboxFetchMode);
            dm_TaiKhoanCo_ThueNK_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanCoThueNKChanged);
            dm_TaiKhoanCo_ThueNK_CollectionViewSource.Source = new List<object> { dm_TaiKhoanCo_ThueNK_ListViewModel };

            System.Windows.Data.CollectionViewSource dm_TaiKhoanNo_ThueNK_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_ThueNK_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel dm_TaiKhoanNo_ThueNK_ListViewModel = new DM_TaiKhoan_ListViewModel(BusinessConfiguration.Configuration.ComboboxFetchMode);
            dm_TaiKhoanNo_ThueNK_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanNoThueNKChanged);
            dm_TaiKhoanNo_ThueNK_CollectionViewSource.Source = new List<object> { dm_TaiKhoanNo_ThueNK_ListViewModel };


            System.Windows.Data.CollectionViewSource dm_TaiKhoanNo_ThueTTDB_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_ThueTTDB_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel dm_TaiKhoanNo_ThueTTDB_ListViewModel = new DM_TaiKhoan_ListViewModel(BusinessConfiguration.Configuration.ComboboxFetchMode);
            dm_TaiKhoanNo_ThueTTDB_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanNoThueTTDBChanged);
            dm_TaiKhoanNo_ThueTTDB_CollectionViewSource.Source = new List<object> { dm_TaiKhoanNo_ThueTTDB_ListViewModel };


            System.Windows.Data.CollectionViewSource dm_TaiKhoanCo_ThueTTDB_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_ThueTTDB_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel dm_TaiKhoanCo_ThueTTDB_ListViewModel = new DM_TaiKhoan_ListViewModel(BusinessConfiguration.Configuration.ComboboxFetchMode);
            dm_TaiKhoanCo_ThueTTDB_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanCoThueTTDBChanged);
            dm_TaiKhoanCo_ThueTTDB_CollectionViewSource.Source = new List<object> { dm_TaiKhoanCo_ThueTTDB_ListViewModel };
        
        }
        public void DoFilterDKNV1And2()
        {
            List<string> taiKhoanNoChiTiet = new List<string>();
            taiKhoanNoChiTiet.Add("151");
            taiKhoanNoChiTiet.Add("1521");
            taiKhoanNoChiTiet.Add("1531");
            taiKhoanNoChiTiet.Add("1561");
            taiKhoanNoChiTiet.Add("1567");
            taiKhoanNoChiTiet.Add("158");
            taiKhoanNoChiTiet.Add("611");

            List<string> taiKhoanCoChiTiet = new List<string>();
            taiKhoanCoChiTiet.Add("331");

            System.Windows.Data.CollectionViewSource dm_TaiKhoanNoChiTiet_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_ChiTiet_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanNoChiTiet_ListViewModel = ((List<object>)dm_TaiKhoanNoChiTiet_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanNoChiTiet_ListViewModel.filterDKNV(taiKhoanNoChiTiet);
            taiKhoanNoChiTiet_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanNoChiTietChanged);

            System.Windows.Data.CollectionViewSource dm_TaiKhoanCo_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_ChiTiet_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanCoChiTiet_ListViewModel = ((List<object>)dm_TaiKhoanCo_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanCoChiTiet_ListViewModel.filterDKNV(taiKhoanCoChiTiet);
            taiKhoanCoChiTiet_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanCoChiTietChanged);

            List<string> taiKhoanNoThue = new List<string>();
            taiKhoanNoThue.Add("1331");

            List<string> taiKhoanCoThue = new List<string>();
            taiKhoanCoThue.Add("331");

            System.Windows.Data.CollectionViewSource dm_TaiKhoanNoThue_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_Thue_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanNoThue_ListViewModel = ((List<object>)dm_TaiKhoanNoThue_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanNoThue_ListViewModel.filterDKNV(taiKhoanNoThue);
            taiKhoanNoThue_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanNoThueChanged);

            System.Windows.Data.CollectionViewSource dm_TaiKhoanCoThue_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_Thue_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanCoThue_ListViewModel = ((List<object>)dm_TaiKhoanCoThue_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanCoThue_ListViewModel.filterDKNV(taiKhoanCoThue);
            taiKhoanCoThue_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanCoThueChanged);
            
            List<string> taiKhoanNoChiPhiMuaHang = new List<string>();
            taiKhoanNoChiPhiMuaHang.Add("151");
            taiKhoanNoChiPhiMuaHang.Add("1521");
            taiKhoanNoChiPhiMuaHang.Add("1531");
            taiKhoanNoChiPhiMuaHang.Add("1561");
            taiKhoanNoChiPhiMuaHang.Add("1567");
            taiKhoanNoChiPhiMuaHang.Add("158");
            taiKhoanNoChiPhiMuaHang.Add("611");

            List<string> taiKhoanCoChiPhiMuaHang = new List<string>();
            taiKhoanCoChiPhiMuaHang.Add("1522");
            taiKhoanCoChiPhiMuaHang.Add("1532");
            taiKhoanCoChiPhiMuaHang.Add("1562");

            System.Windows.Data.CollectionViewSource dm_TaiKhoanNoChiPhiMuaHang_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_ChiPhiMuaHang_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanNoChiPhiMuaHang_ListViewModel = ((List<object>)dm_TaiKhoanNoChiPhiMuaHang_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanNoChiPhiMuaHang_ListViewModel.filterDKNV(taiKhoanNoChiPhiMuaHang);
            taiKhoanNoChiPhiMuaHang_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanNoChiPhiMuaHangChanged);

            System.Windows.Data.CollectionViewSource dm_TaiKhoanCoChiPhiMuaHang_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_ChiPhiMuaHang_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanCoChiPhiMuaHang_ListViewModel = ((List<object>)dm_TaiKhoanCoChiPhiMuaHang_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanCoChiPhiMuaHang_ListViewModel.filterDKNV(taiKhoanCoChiPhiMuaHang);
            taiKhoanCoChiPhiMuaHang_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanCoChiPhiMuaHangChanged);

            List<string> taiKhoanNoTSThieuCXL = new List<string>();
            taiKhoanNoTSThieuCXL.Add("1381");

            List<string> taiKhoanCoTSThieuCXL = new List<string>();
            taiKhoanCoTSThieuCXL.Add("331");

            System.Windows.Data.CollectionViewSource dm_TaiKhoanNoTSThieuCXL_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_TSThieuCXL_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanNoTSThieuCXL_ListViewModel = ((List<object>)dm_TaiKhoanNoTSThieuCXL_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanNoTSThieuCXL_ListViewModel.filterDKNV(taiKhoanNoTSThieuCXL);
            taiKhoanNoTSThieuCXL_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanNoTSThieuCXLChanged);

            System.Windows.Data.CollectionViewSource dm_TaiKhoanCoTSThieuCXL_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_TSThieuCXL_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanCoTSThieuCXL_ListViewModel = ((List<object>)dm_TaiKhoanCoTSThieuCXL_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanCoTSThieuCXL_ListViewModel.filterDKNV(taiKhoanCoTSThieuCXL);
            taiKhoanCoTSThieuCXL_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanCoTSThieuCXLChanged);

            List<string> taiKhoanNoTSThuaCXL = new List<string>();
            taiKhoanNoTSThuaCXL.Add("1521");
            taiKhoanNoTSThuaCXL.Add("1531");
            taiKhoanNoTSThuaCXL.Add("1561");
            taiKhoanNoTSThuaCXL.Add("1567");
            taiKhoanNoTSThuaCXL.Add("158");
            taiKhoanNoTSThuaCXL.Add("611");

            List<string> taiKhoanCoTSThuaCXL = new List<string>();
            taiKhoanCoTSThuaCXL.Add("3381");

            System.Windows.Data.CollectionViewSource dm_TaiKhoanNoTSThuaCXL_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_TSThuaCXL_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanNoTSThuaCXL_ListViewModel = ((List<object>)dm_TaiKhoanNoTSThuaCXL_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanNoTSThuaCXL_ListViewModel.filterDKNV(taiKhoanNoTSThuaCXL);
            taiKhoanNoTSThuaCXL_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanNoTSThuaCXLChanged);

            System.Windows.Data.CollectionViewSource dm_TaiKhoanCoTSThuaCXL_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_TSThuaCXL_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanCoTSThuaCXL_ListViewModel = ((List<object>)dm_TaiKhoanCoTSThuaCXL_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanCoTSThuaCXL_ListViewModel.filterDKNV(taiKhoanCoTSThuaCXL);
            taiKhoanCoTSThuaCXL_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanCoTSThuaCXLChanged);


            System.Windows.Data.CollectionViewSource dm_TaiKhoanNoThueNK_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_ThueNK_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanNoThueNK_ListViewModel = ((List<object>)dm_TaiKhoanNoThueNK_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanNoThueNK_ListViewModel.GetDM_TaiKhoan_ListViewModel(BusinessConfiguration.Configuration.ComboboxFetchMode) ;
            taiKhoanNoThueNK_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanNoThueNKChanged);

            System.Windows.Data.CollectionViewSource dm_TaiKhoanCoThueNK_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_ThueNK_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanCoThueNK_ListViewModel = ((List<object>)dm_TaiKhoanCoThueNK_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanCoThueNK_ListViewModel.GetDM_TaiKhoan_ListViewModel(BusinessConfiguration.Configuration.ComboboxFetchMode);
            taiKhoanCoThueNK_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanCoThueNKChanged);

            System.Windows.Data.CollectionViewSource dm_TaiKhoanNoThueTTDB_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_ThueTTDB_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanNoThueTTDB_ListViewModel = ((List<object>)dm_TaiKhoanNoThueTTDB_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanNoThueTTDB_ListViewModel.GetDM_TaiKhoan_ListViewModel(BusinessConfiguration.Configuration.ComboboxFetchMode);
            taiKhoanNoThueTTDB_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanNoThueTTDBChanged);

            System.Windows.Data.CollectionViewSource dm_TaiKhoanCoThueTTDB_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_ThueTTDB_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanCoThueTTDB_ListViewModel = ((List<object>)dm_TaiKhoanCoThueTTDB_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanCoThueTTDB_ListViewModel.GetDM_TaiKhoan_ListViewModel(BusinessConfiguration.Configuration.ComboboxFetchMode);
            taiKhoanCoThueTTDB_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanCoThueTTDBChanged);
        }
                    
        public void DoFilterDKNV3And4()
        {
            List<string> taiKhoanNoChiTiet = new List<string>();
            taiKhoanNoChiTiet.Add("151");
            taiKhoanNoChiTiet.Add("1521");
            taiKhoanNoChiTiet.Add("1531");
            taiKhoanNoChiTiet.Add("1561");
            taiKhoanNoChiTiet.Add("1567");
            taiKhoanNoChiTiet.Add("158");
            taiKhoanNoChiTiet.Add("611");

            List<string> taiKhoanCoChiTiet = new List<string>();
            taiKhoanCoChiTiet.Add("331");

            System.Windows.Data.CollectionViewSource dm_TaiKhoanNoChiTiet_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_ChiTiet_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanNoChiTiet_ListViewModel = ((List<object>)dm_TaiKhoanNoChiTiet_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanNoChiTiet_ListViewModel.filterDKNV(taiKhoanNoChiTiet);
            taiKhoanNoChiTiet_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanNoChiTietChanged);

            System.Windows.Data.CollectionViewSource dm_TaiKhoanCo_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_ChiTiet_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanCoChiTiet_ListViewModel = ((List<object>)dm_TaiKhoanCo_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanCoChiTiet_ListViewModel.filterDKNV(taiKhoanCoChiTiet);
            taiKhoanCoChiTiet_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanCoChiTietChanged);
            
            List<string> taiKhoanNoThue = new List<string>();
            taiKhoanNoThue.Add("1331");

            List<string> taiKhoanCoThue = new List<string>();
            taiKhoanCoThue.Add("33312");

            System.Windows.Data.CollectionViewSource dm_TaiKhoanNoThue_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_Thue_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanNoThue_ListViewModel = ((List<object>)dm_TaiKhoanNoThue_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanNoThue_ListViewModel.filterDKNV(taiKhoanNoThue);
            taiKhoanNoThue_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanNoThueChanged);

            System.Windows.Data.CollectionViewSource dm_TaiKhoanCoThue_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_Thue_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanCoThue_ListViewModel = ((List<object>)dm_TaiKhoanCoThue_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanCoThue_ListViewModel.filterDKNV(taiKhoanCoThue);
            taiKhoanCoThue_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanCoThueChanged);

            

            List<string> taiKhoanNoChiPhiMuaHang = new List<string>();
            taiKhoanNoChiPhiMuaHang.Add("151");
            taiKhoanNoChiPhiMuaHang.Add("1521");
            taiKhoanNoChiPhiMuaHang.Add("1531");
            taiKhoanNoChiPhiMuaHang.Add("1561");
            taiKhoanNoChiPhiMuaHang.Add("1567");
            taiKhoanNoChiPhiMuaHang.Add("158");
            taiKhoanNoChiPhiMuaHang.Add("611");

            List<string> taiKhoanCoChiPhiMuaHang = new List<string>();
            taiKhoanCoChiPhiMuaHang.Add("1522");
            taiKhoanCoChiPhiMuaHang.Add("1532");
            taiKhoanNoChiPhiMuaHang.Add("1562");

            System.Windows.Data.CollectionViewSource dm_TaiKhoanNoChiPhiMuaHang_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_ChiPhiMuaHang_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanNoChiPhiMuaHang_ListViewModel = ((List<object>)dm_TaiKhoanNoChiPhiMuaHang_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanNoChiPhiMuaHang_ListViewModel.filterDKNV(taiKhoanNoChiPhiMuaHang);

            System.Windows.Data.CollectionViewSource dm_TaiKhoanCoChiPhiMuaHang_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_ChiPhiMuaHang_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanCoChiPhiMuaHang_ListViewModel = ((List<object>)dm_TaiKhoanCoChiPhiMuaHang_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanCoChiPhiMuaHang_ListViewModel.filterDKNV(taiKhoanCoChiPhiMuaHang);

            taiKhoanNoChiPhiMuaHang_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanNoChiPhiMuaHangChanged);
            taiKhoanCoChiPhiMuaHang_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanCoChiPhiMuaHangChanged);

            List<string> taiKhoanNoTSThieuCXL = new List<string>();
            taiKhoanNoTSThieuCXL.Add("1381");

            List<string> taiKhoanCoTSThieuCXL = new List<string>();
            taiKhoanCoTSThieuCXL.Add("331");

            System.Windows.Data.CollectionViewSource dm_TaiKhoanNoTSThieuCXL_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_TSThieuCXL_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanNoTSThieuCXL_ListViewModel = ((List<object>)dm_TaiKhoanNoTSThieuCXL_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanNoTSThieuCXL_ListViewModel.filterDKNV(taiKhoanNoTSThieuCXL);

            System.Windows.Data.CollectionViewSource dm_TaiKhoanCoTSThieuCXL_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_TSThieuCXL_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanCoTSThieuCXL_ListViewModel = ((List<object>)dm_TaiKhoanCoTSThieuCXL_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanCoTSThieuCXL_ListViewModel.filterDKNV(taiKhoanCoTSThieuCXL);

            taiKhoanNoTSThieuCXL_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanNoTSThieuCXLChanged);
            taiKhoanCoTSThieuCXL_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanCoTSThieuCXLChanged);
           

            List<string> taiKhoanNoTSThuaCXL = new List<string>();
            taiKhoanNoTSThuaCXL.Add("1521");
            taiKhoanNoTSThuaCXL.Add("1531");
            taiKhoanNoTSThuaCXL.Add("1561");
            taiKhoanNoTSThuaCXL.Add("1567");
            taiKhoanNoTSThuaCXL.Add("158");
            taiKhoanNoTSThuaCXL.Add("611");

            List<string> taiKhoanCoTSThuaCXL = new List<string>();
            taiKhoanCoTSThuaCXL.Add("3381");

            System.Windows.Data.CollectionViewSource dm_TaiKhoanNoTSThuaCXL_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_TSThuaCXL_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanNoTSThuaCXL_ListViewModel = ((List<object>)dm_TaiKhoanNoTSThuaCXL_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanNoTSThuaCXL_ListViewModel.filterDKNV(taiKhoanNoTSThuaCXL);

            System.Windows.Data.CollectionViewSource dm_TaiKhoanCoTSThuaCXL_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_TSThuaCXL_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanCoTSThuaCXL_ListViewModel = ((List<object>)dm_TaiKhoanCoTSThuaCXL_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanCoTSThuaCXL_ListViewModel.filterDKNV(taiKhoanCoTSThuaCXL);

            taiKhoanNoTSThuaCXL_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanNoTSThuaCXLChanged);
            taiKhoanCoTSThuaCXL_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanCoTSThuaCXLChanged);

            List<string> taiKhoanNoThueNK = new List<string>();
            taiKhoanNoThueNK.Add("151");
            taiKhoanNoThueNK.Add("1521");
            taiKhoanNoThueNK.Add("1531");
            taiKhoanNoThueNK.Add("1561");
            taiKhoanNoThueNK.Add("1567");
            taiKhoanNoThueNK.Add("158");
            taiKhoanNoThueNK.Add("611");

            List<string> taiKhoanCoThueNK = new List<string>();
            taiKhoanCoThueNK.Add("3333");

            System.Windows.Data.CollectionViewSource dm_TaiKhoanNoThueNK_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_ThueNK_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanNoThueNK_ListViewModel = ((List<object>)dm_TaiKhoanNoThueNK_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanNoThueNK_ListViewModel.filterDKNV(taiKhoanNoThueNK);

            System.Windows.Data.CollectionViewSource dm_TaiKhoanCoThueNK_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_ThueNK_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanCoThueNK_ListViewModel = ((List<object>)dm_TaiKhoanCoThueNK_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanCoThueNK_ListViewModel.filterDKNV(taiKhoanCoThueNK);

            taiKhoanNoThueNK_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanNoThueNKChanged);
            taiKhoanCoThueNK_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanCoThueNKChanged);

            List<string> taiKhoanNoThueTTDB = new List<string>();
            taiKhoanNoThueTTDB.Add("151");
            taiKhoanNoThueTTDB.Add("1521");
            taiKhoanNoThueTTDB.Add("1531");
            taiKhoanNoThueTTDB.Add("1561");
            taiKhoanNoThueTTDB.Add("1567");
            taiKhoanNoThueTTDB.Add("158");
            taiKhoanNoThueTTDB.Add("611");

            List<string> taiKhoanCoThueTTDB = new List<string>();
            taiKhoanCoThueTTDB.Add("3332");

            System.Windows.Data.CollectionViewSource dm_TaiKhoanNoThueTTDB_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_ThueTTDB_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanNoThueTTDB_ListViewModel = ((List<object>)dm_TaiKhoanNoThueTTDB_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanNoThueTTDB_ListViewModel.filterDKNV(taiKhoanNoThueTTDB);

            System.Windows.Data.CollectionViewSource dm_TaiKhoanCoThueTTDB_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_ThueTTDB_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanCoThueTTDB_ListViewModel = ((List<object>)dm_TaiKhoanCoThueTTDB_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanCoThueTTDB_ListViewModel.filterDKNV(taiKhoanCoThueTTDB);

            taiKhoanNoThueTTDB_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanNoThueTTDBChanged);
            taiKhoanCoThueTTDB_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanCoThueTTDBChanged);

            
        }

        public void DoFilterDKNV5()
        {
            List<string> taiKhoanNoChiTiet = new List<string>();
            taiKhoanNoChiTiet.Add("151");
            taiKhoanNoChiTiet.Add("1521");
            taiKhoanNoChiTiet.Add("1531");
            taiKhoanNoChiTiet.Add("1561");
            taiKhoanNoChiTiet.Add("1567");
            taiKhoanNoChiTiet.Add("158");
            taiKhoanNoChiTiet.Add("611");

            List<string> taiKhoanCoChiTiet = new List<string>();
            taiKhoanCoChiTiet.Add("1111");
            taiKhoanCoChiTiet.Add("1121");

            System.Windows.Data.CollectionViewSource dm_TaiKhoanNoChiTiet_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_ChiTiet_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanNoChiTiet_ListViewModel = ((List<object>)dm_TaiKhoanNoChiTiet_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanNoChiTiet_ListViewModel.filterDKNV(taiKhoanNoChiTiet);

            System.Windows.Data.CollectionViewSource dm_TaiKhoanCo_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_ChiTiet_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanCoChiTiet_ListViewModel = ((List<object>)dm_TaiKhoanCo_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanCoChiTiet_ListViewModel.filterDKNV(taiKhoanCoChiTiet);

            List<string> taiKhoanNoThue = new List<string>();
            taiKhoanNoThue.Add("1331");

            List<string> taiKhoanCoThue = new List<string>();
            taiKhoanCoThue.Add("1111");
            taiKhoanCoThue.Add("1121");

            System.Windows.Data.CollectionViewSource dm_TaiKhoanNoThue_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_Thue_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanNoThue_ListViewModel = ((List<object>)dm_TaiKhoanNoThue_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanNoThue_ListViewModel.filterDKNV(taiKhoanNoThue);

            System.Windows.Data.CollectionViewSource dm_TaiKhoanCoThue_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_Thue_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanCoThue_ListViewModel = ((List<object>)dm_TaiKhoanCoThue_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanCoThue_ListViewModel.filterDKNV(taiKhoanCoThue);


            List<string> taiKhoanNoChiPhiMuaHang = new List<string>();
            taiKhoanNoChiPhiMuaHang.Add("151");
            taiKhoanNoChiPhiMuaHang.Add("1521");
            taiKhoanNoChiPhiMuaHang.Add("1531");
            taiKhoanNoChiPhiMuaHang.Add("1561");
            taiKhoanNoChiPhiMuaHang.Add("1567");
            taiKhoanNoChiPhiMuaHang.Add("158");
            taiKhoanNoChiPhiMuaHang.Add("611");

            List<string> taiKhoanCoChiPhiMuaHang = new List<string>();
            taiKhoanCoChiPhiMuaHang.Add("1522");
            taiKhoanCoChiPhiMuaHang.Add("1532");
            taiKhoanCoChiPhiMuaHang.Add("1562");

            System.Windows.Data.CollectionViewSource dm_TaiKhoanNoChiPhiMuaHang_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_ChiPhiMuaHang_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanNoChiPhiMuaHang_ListViewModel = ((List<object>)dm_TaiKhoanNoChiPhiMuaHang_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanNoChiPhiMuaHang_ListViewModel.filterDKNV(taiKhoanNoChiPhiMuaHang);

            System.Windows.Data.CollectionViewSource dm_TaiKhoanCoChiPhiMuaHang_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_ChiPhiMuaHang_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanCoChiPhiMuaHang_ListViewModel = ((List<object>)dm_TaiKhoanCoChiPhiMuaHang_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanCoChiPhiMuaHang_ListViewModel.filterDKNV(taiKhoanCoChiPhiMuaHang);

            List<string> taiKhoanNoTSThieuCXL = new List<string>();
            taiKhoanNoTSThieuCXL.Add("1381");

            List<string> taiKhoanCoTSThieuCXL = new List<string>();
            taiKhoanCoTSThieuCXL.Add("1111");
            taiKhoanCoTSThieuCXL.Add("1121");

            System.Windows.Data.CollectionViewSource dm_TaiKhoanNoTSThieuCXL_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_TSThieuCXL_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanNoTSThieuCXL_ListViewModel = ((List<object>)dm_TaiKhoanNoTSThieuCXL_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanNoTSThieuCXL_ListViewModel.filterDKNV(taiKhoanNoTSThieuCXL);

            System.Windows.Data.CollectionViewSource dm_TaiKhoanCoTSThieuCXL_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_TSThieuCXL_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanCoTSThieuCXL_ListViewModel = ((List<object>)dm_TaiKhoanCoTSThieuCXL_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanCoTSThieuCXL_ListViewModel.filterDKNV(taiKhoanCoTSThieuCXL);


            List<string> taiKhoanNoTSThuaCXL = new List<string>();
            taiKhoanNoTSThuaCXL.Add("1521");
            taiKhoanNoTSThuaCXL.Add("1531");
            taiKhoanNoTSThuaCXL.Add("1561");
            taiKhoanNoTSThuaCXL.Add("1567");
            taiKhoanNoTSThuaCXL.Add("158");
            taiKhoanNoTSThuaCXL.Add("611");

            List<string> taiKhoanCoTSThuaCXL = new List<string>();
            taiKhoanCoTSThuaCXL.Add("3381");

            System.Windows.Data.CollectionViewSource dm_TaiKhoanNoTSThuaCXL_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_TSThuaCXL_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanNoTSThuaCXL_ListViewModel = ((List<object>)dm_TaiKhoanNoTSThuaCXL_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanNoTSThuaCXL_ListViewModel.filterDKNV(taiKhoanNoTSThuaCXL);

            System.Windows.Data.CollectionViewSource dm_TaiKhoanCoTSThuaCXL_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_TSThuaCXL_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanCoTSThuaCXL_ListViewModel = ((List<object>)dm_TaiKhoanCoTSThuaCXL_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanCoTSThuaCXL_ListViewModel.filterDKNV(taiKhoanCoTSThuaCXL);

            taiKhoanNoChiTiet_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanNoChiTietChanged);
            taiKhoanCoChiTiet_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanCoChiTietChanged);
            taiKhoanNoThue_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanNoThueChanged);
            taiKhoanCoThue_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanCoThueChanged);
            taiKhoanNoChiPhiMuaHang_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanNoChiPhiMuaHangChanged);
            taiKhoanCoChiPhiMuaHang_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanCoChiPhiMuaHangChanged);
            taiKhoanNoTSThieuCXL_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanNoTSThieuCXLChanged);
            taiKhoanCoTSThieuCXL_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanCoTSThieuCXLChanged);
            taiKhoanNoTSThuaCXL_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanNoTSThuaCXLChanged);
            taiKhoanCoTSThuaCXL_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanCoTSThuaCXLChanged);

            System.Windows.Data.CollectionViewSource dm_TaiKhoanNoThueNK_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_ThueNK_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanNoThueNK_ListViewModel = ((List<object>)dm_TaiKhoanNoThueNK_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanNoThueNK_ListViewModel.GetDM_TaiKhoan_ListViewModel(BusinessConfiguration.Configuration.ComboboxFetchMode);
            taiKhoanNoThueNK_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanNoThueNKChanged);

            System.Windows.Data.CollectionViewSource dm_TaiKhoanCoThueNK_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_ThueNK_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanCoThueNK_ListViewModel = ((List<object>)dm_TaiKhoanCoThueNK_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanCoThueNK_ListViewModel.GetDM_TaiKhoan_ListViewModel(BusinessConfiguration.Configuration.ComboboxFetchMode);
            taiKhoanCoThueNK_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanCoThueNKChanged);

            System.Windows.Data.CollectionViewSource dm_TaiKhoanNoThueTTDB_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_ThueTTDB_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanNoThueTTDB_ListViewModel = ((List<object>)dm_TaiKhoanNoThueTTDB_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanNoThueTTDB_ListViewModel.GetDM_TaiKhoan_ListViewModel(BusinessConfiguration.Configuration.ComboboxFetchMode);
            taiKhoanNoThueTTDB_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanNoThueTTDBChanged);

            System.Windows.Data.CollectionViewSource dm_TaiKhoanCoThueTTDB_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_ThueTTDB_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanCoThueTTDB_ListViewModel = ((List<object>)dm_TaiKhoanCoThueTTDB_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanCoThueTTDB_ListViewModel.GetDM_TaiKhoan_ListViewModel(BusinessConfiguration.Configuration.ComboboxFetchMode);
            taiKhoanCoThueTTDB_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanCoThueTTDBChanged);
        }
                    
        public void DoFilterDKNV6()
        {
            List<string> taiKhoanNoChiTiet = new List<string>();
            taiKhoanNoChiTiet.Add("151");
            taiKhoanNoChiTiet.Add("1521");
            taiKhoanNoChiTiet.Add("1531");
            taiKhoanNoChiTiet.Add("1561");
            taiKhoanNoChiTiet.Add("1567");
            taiKhoanNoChiTiet.Add("611");
            taiKhoanNoChiTiet.Add("635");

            List<string> taiKhoanCoChiTiet = new List<string>();
            taiKhoanCoChiTiet.Add("1112");
            taiKhoanCoChiTiet.Add("1113");
            taiKhoanCoChiTiet.Add("1122");
            taiKhoanCoChiTiet.Add("1123");
            taiKhoanCoChiTiet.Add("515");

            System.Windows.Data.CollectionViewSource dm_TaiKhoanNoChiTiet_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_ChiTiet_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanNoChiTiet_ListViewModel = ((List<object>)dm_TaiKhoanNoChiTiet_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanNoChiTiet_ListViewModel.filterDKNV(taiKhoanNoChiTiet);

            System.Windows.Data.CollectionViewSource dm_TaiKhoanCoChiTiet_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_ChiTiet_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanCoChiTiet_ListViewModel = ((List<object>)dm_TaiKhoanCoChiTiet_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanCoChiTiet_ListViewModel.filterDKNV(taiKhoanCoChiTiet);

            List<string> taiKhoanNoThue = new List<string>();
            taiKhoanNoThue.Add("1331");
            taiKhoanNoThue.Add("635");

            List<string> taiKhoanCoThue = new List<string>();
            taiKhoanCoThue.Add("1112");
            taiKhoanCoThue.Add("1113");
            taiKhoanCoThue.Add("1122");
            taiKhoanCoThue.Add("1123");
            taiKhoanCoThue.Add("515");


            System.Windows.Data.CollectionViewSource dm_TaiKhoanNoThue_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_Thue_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanNoThue_ListViewModel = ((List<object>)dm_TaiKhoanNoThue_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanNoThue_ListViewModel.filterDKNV(taiKhoanNoThue);

            System.Windows.Data.CollectionViewSource dm_TaiKhoanCoThue_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_Thue_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanCoThue_ListViewModel = ((List<object>)dm_TaiKhoanCoThue_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanCoThue_ListViewModel.filterDKNV(taiKhoanCoThue);


            List<string> taiKhoanNoChiPhiMuaHang = new List<string>();
            taiKhoanNoChiPhiMuaHang.Add("151");
            taiKhoanNoChiPhiMuaHang.Add("1521");
            taiKhoanNoChiPhiMuaHang.Add("1531");
            taiKhoanNoChiPhiMuaHang.Add("1561");
            taiKhoanNoChiPhiMuaHang.Add("1567");
            taiKhoanNoChiPhiMuaHang.Add("158");
            taiKhoanNoChiPhiMuaHang.Add("611");

            List<string> taiKhoanCoChiPhiMuaHang = new List<string>();
            taiKhoanCoChiPhiMuaHang.Add("1522");
            taiKhoanCoChiPhiMuaHang.Add("1532");
            taiKhoanCoChiPhiMuaHang.Add("1562");

            System.Windows.Data.CollectionViewSource dm_TaiKhoanNoChiPhiMuaHang_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_ChiPhiMuaHang_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanNoChiPhiMuaHang_ListViewModel = ((List<object>)dm_TaiKhoanNoChiPhiMuaHang_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanNoChiPhiMuaHang_ListViewModel.filterDKNV(taiKhoanNoChiPhiMuaHang);

            System.Windows.Data.CollectionViewSource dm_TaiKhoanCoChiPhiMuaHang_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_ChiPhiMuaHang_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanCoChiPhiMuaHang_ListViewModel = ((List<object>)dm_TaiKhoanCoChiPhiMuaHang_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanCoChiPhiMuaHang_ListViewModel.filterDKNV(taiKhoanCoChiPhiMuaHang);

            List<string> taiKhoanNoTSThieuCXL = new List<string>();
            taiKhoanNoTSThieuCXL.Add("1381");
            taiKhoanNoTSThieuCXL.Add("635");

            List<string> taiKhoanCoTSThieuCXL = new List<string>();
            taiKhoanCoTSThieuCXL.Add("1111");
            taiKhoanCoTSThieuCXL.Add("1121");
            taiKhoanCoTSThieuCXL.Add("515");

            System.Windows.Data.CollectionViewSource dm_TaiKhoanNoTSThieuCXL_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_TSThieuCXL_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanNoTSThieuCXL_ListViewModel = ((List<object>)dm_TaiKhoanNoTSThieuCXL_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanNoTSThieuCXL_ListViewModel.filterDKNV(taiKhoanNoTSThieuCXL);

            System.Windows.Data.CollectionViewSource dm_TaiKhoanCoTSThieuCXL_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_TSThieuCXL_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanCoTSThieuCXL_ListViewModel = ((List<object>)dm_TaiKhoanCoTSThieuCXL_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanCoTSThieuCXL_ListViewModel.filterDKNV(taiKhoanCoTSThieuCXL);


            List<string> taiKhoanNoTSThuaCXL = new List<string>();
            taiKhoanNoTSThuaCXL.Add("1521");
            taiKhoanNoTSThuaCXL.Add("1531");
            taiKhoanNoTSThuaCXL.Add("1561");
            taiKhoanNoTSThuaCXL.Add("1567");
            taiKhoanNoTSThuaCXL.Add("158");
            taiKhoanNoTSThuaCXL.Add("611");

            List<string> taiKhoanCoTSThuaCXL = new List<string>();
            taiKhoanCoTSThuaCXL.Add("3381");

            System.Windows.Data.CollectionViewSource dm_TaiKhoanNoTSThuaCXL_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_TSThuaCXL_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanNoTSThuaCXL_ListViewModel = ((List<object>)dm_TaiKhoanNoTSThuaCXL_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanNoTSThuaCXL_ListViewModel.filterDKNV(taiKhoanNoTSThuaCXL);

            System.Windows.Data.CollectionViewSource dm_TaiKhoanCoTSThuaCXL_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_TSThuaCXL_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanCoTSThuaCXL_ListViewModel = ((List<object>)dm_TaiKhoanCoTSThuaCXL_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanCoTSThuaCXL_ListViewModel.filterDKNV(taiKhoanCoTSThuaCXL);

            taiKhoanNoChiTiet_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanNoChiTietChanged);
            taiKhoanCoChiTiet_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanCoChiTietChanged);
            taiKhoanNoThue_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanNoThueChanged);
            taiKhoanCoThue_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanCoThueChanged);
            taiKhoanNoChiPhiMuaHang_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanNoChiPhiMuaHangChanged);
            taiKhoanCoChiPhiMuaHang_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanCoChiPhiMuaHangChanged);
            taiKhoanNoTSThieuCXL_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanNoTSThieuCXLChanged);
            taiKhoanCoTSThieuCXL_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanCoTSThieuCXLChanged);
            taiKhoanNoTSThuaCXL_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanNoTSThuaCXLChanged);
            taiKhoanCoTSThuaCXL_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanCoTSThuaCXLChanged);


            System.Windows.Data.CollectionViewSource dm_TaiKhoanNoThueNK_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_ThueNK_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanNoThueNK_ListViewModel = ((List<object>)dm_TaiKhoanNoThueNK_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanNoThueNK_ListViewModel.GetDM_TaiKhoan_ListViewModel(BusinessConfiguration.Configuration.ComboboxFetchMode);
            taiKhoanNoThueNK_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanNoThueNKChanged);

            System.Windows.Data.CollectionViewSource dm_TaiKhoanCoThueNK_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_ThueNK_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanCoThueNK_ListViewModel = ((List<object>)dm_TaiKhoanCoThueNK_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanCoThueNK_ListViewModel.GetDM_TaiKhoan_ListViewModel(BusinessConfiguration.Configuration.ComboboxFetchMode);
            taiKhoanCoThueNK_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanCoThueNKChanged);

            System.Windows.Data.CollectionViewSource dm_TaiKhoanNoThueTTDB_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_ThueTTDB_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanNoThueTTDB_ListViewModel = ((List<object>)dm_TaiKhoanNoThueTTDB_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanNoThueTTDB_ListViewModel.GetDM_TaiKhoan_ListViewModel(BusinessConfiguration.Configuration.ComboboxFetchMode);
            taiKhoanNoThueTTDB_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanNoThueTTDBChanged);

            System.Windows.Data.CollectionViewSource dm_TaiKhoanCoThueTTDB_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_ThueTTDB_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanCoThueTTDB_ListViewModel = ((List<object>)dm_TaiKhoanCoThueTTDB_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanCoThueTTDB_ListViewModel.GetDM_TaiKhoan_ListViewModel(BusinessConfiguration.Configuration.ComboboxFetchMode);
            taiKhoanCoThueTTDB_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanCoThueTTDBChanged);
        }
                    
        public void DoFilterDKNV7()
        {
            List<string> taiKhoanNoChiTiet = new List<string>();
            taiKhoanNoChiTiet.Add("151");
            taiKhoanNoChiTiet.Add("1521");
            taiKhoanNoChiTiet.Add("1531");
            taiKhoanNoChiTiet.Add("1561");
            taiKhoanNoChiTiet.Add("1567");
            taiKhoanNoChiTiet.Add("158");
            taiKhoanNoChiTiet.Add("611");

            List<string> taiKhoanCoChiTiet = new List<string>();
            taiKhoanCoChiTiet.Add("1111");
            taiKhoanCoChiTiet.Add("1121");

            System.Windows.Data.CollectionViewSource dm_TaiKhoanNoChiTiet_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_ChiTiet_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanNoChiTiet_ListViewModel = ((List<object>)dm_TaiKhoanNoChiTiet_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanNoChiTiet_ListViewModel.filterDKNV(taiKhoanNoChiTiet);

            System.Windows.Data.CollectionViewSource dm_TaiKhoanCo_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_ChiTiet_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanCoChiTiet_ListViewModel = ((List<object>)dm_TaiKhoanCo_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanCoChiTiet_ListViewModel.filterDKNV(taiKhoanCoChiTiet);

            List<string> taiKhoanNoThue = new List<string>();
            taiKhoanNoThue.Add("1331");

            List<string> taiKhoanCoThue = new List<string>();
            taiKhoanCoThue.Add("33312");

            System.Windows.Data.CollectionViewSource dm_TaiKhoanNoThue_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_Thue_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanNoThue_ListViewModel = ((List<object>)dm_TaiKhoanNoThue_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanNoThue_ListViewModel.filterDKNV(taiKhoanNoThue);

            System.Windows.Data.CollectionViewSource dm_TaiKhoanCoThue_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_Thue_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanCoThue_ListViewModel = ((List<object>)dm_TaiKhoanCoThue_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanCoThue_ListViewModel.filterDKNV(taiKhoanCoThue);


            List<string> taiKhoanNoChiPhiMuaHang = new List<string>();
            taiKhoanNoChiPhiMuaHang.Add("151");
            taiKhoanNoChiPhiMuaHang.Add("1521");
            taiKhoanNoChiPhiMuaHang.Add("1531");
            taiKhoanNoChiPhiMuaHang.Add("1561");
            taiKhoanNoChiPhiMuaHang.Add("1567");
            taiKhoanNoChiPhiMuaHang.Add("158");
            taiKhoanNoChiPhiMuaHang.Add("611");

            List<string> taiKhoanCoChiPhiMuaHang = new List<string>();
            taiKhoanCoChiPhiMuaHang.Add("1522");
            taiKhoanCoChiPhiMuaHang.Add("1532");
            taiKhoanNoChiPhiMuaHang.Add("1562");

            System.Windows.Data.CollectionViewSource dm_TaiKhoanNoChiPhiMuaHang_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_ChiPhiMuaHang_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanNoChiPhiMuaHang_ListViewModel = ((List<object>)dm_TaiKhoanNoChiPhiMuaHang_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanNoChiPhiMuaHang_ListViewModel.filterDKNV(taiKhoanNoChiPhiMuaHang);

            System.Windows.Data.CollectionViewSource dm_TaiKhoanCoChiPhiMuaHang_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_ChiPhiMuaHang_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanCoChiPhiMuaHang_ListViewModel = ((List<object>)dm_TaiKhoanCoChiPhiMuaHang_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanCoChiPhiMuaHang_ListViewModel.filterDKNV(taiKhoanCoChiPhiMuaHang);

            List<string> taiKhoanNoTSThieuCXL = new List<string>();
            taiKhoanNoTSThieuCXL.Add("1381");

            List<string> taiKhoanCoTSThieuCXL = new List<string>();
            taiKhoanCoTSThieuCXL.Add("1111");
            taiKhoanCoTSThieuCXL.Add("1121");

            System.Windows.Data.CollectionViewSource dm_TaiKhoanNoTSThieuCXL_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_TSThieuCXL_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanNoTSThieuCXL_ListViewModel = ((List<object>)dm_TaiKhoanNoTSThieuCXL_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanNoTSThieuCXL_ListViewModel.filterDKNV(taiKhoanNoTSThieuCXL);

            System.Windows.Data.CollectionViewSource dm_TaiKhoanCoTSThieuCXL_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_TSThieuCXL_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanCoTSThieuCXL_ListViewModel = ((List<object>)dm_TaiKhoanCoTSThieuCXL_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanCoTSThieuCXL_ListViewModel.filterDKNV(taiKhoanCoTSThieuCXL);


            List<string> taiKhoanNoTSThuaCXL = new List<string>();
            taiKhoanNoTSThuaCXL.Add("1521");
            taiKhoanNoTSThuaCXL.Add("1531");
            taiKhoanNoTSThuaCXL.Add("1561");
            taiKhoanNoTSThuaCXL.Add("1567");
            taiKhoanNoTSThuaCXL.Add("158");
            taiKhoanNoTSThuaCXL.Add("611");

            List<string> taiKhoanCoTSThuaCXL = new List<string>();
            taiKhoanCoTSThuaCXL.Add("3381");

            System.Windows.Data.CollectionViewSource dm_TaiKhoanNoTSThuaCXL_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_TSThuaCXL_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanNoTSThuaCXL_ListViewModel = ((List<object>)dm_TaiKhoanNoTSThuaCXL_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanNoTSThuaCXL_ListViewModel.filterDKNV(taiKhoanNoTSThuaCXL);

            System.Windows.Data.CollectionViewSource dm_TaiKhoanCoTSThuaCXL_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_TSThuaCXL_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanCoTSThuaCXL_ListViewModel = ((List<object>)dm_TaiKhoanCoTSThuaCXL_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanCoTSThuaCXL_ListViewModel.filterDKNV(taiKhoanCoTSThuaCXL);


            List<string> taiKhoanNoThueNK = new List<string>();
            taiKhoanNoThueNK.Add("151");
            taiKhoanNoThueNK.Add("1521");
            taiKhoanNoThueNK.Add("1531");
            taiKhoanNoThueNK.Add("1561");
            taiKhoanNoThueNK.Add("1567");
            taiKhoanNoThueNK.Add("158");
            taiKhoanNoThueNK.Add("611");

            List<string> taiKhoanCoThueNK = new List<string>();
            taiKhoanCoThueNK.Add("3333");

            System.Windows.Data.CollectionViewSource dm_TaiKhoanNoThueNK_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_ThueNK_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanNoThueNK_ListViewModel = ((List<object>)dm_TaiKhoanNoThueNK_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanNoThueNK_ListViewModel.filterDKNV(taiKhoanNoThueNK);

            System.Windows.Data.CollectionViewSource dm_TaiKhoanCoThueNK_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_ThueNK_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanCoThueNK_ListViewModel = ((List<object>)dm_TaiKhoanCoThueNK_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanCoThueNK_ListViewModel.filterDKNV(taiKhoanCoThueNK);


            List<string> taiKhoanNoThueTTDB = new List<string>();
            taiKhoanNoThueTTDB.Add("151");
            taiKhoanNoThueTTDB.Add("1521");
            taiKhoanNoThueTTDB.Add("1531");
            taiKhoanNoThueTTDB.Add("1561");
            taiKhoanNoThueTTDB.Add("1567");
            taiKhoanNoThueTTDB.Add("158");
            taiKhoanNoThueTTDB.Add("611");

            List<string> taiKhoanCoThueTTDB = new List<string>();
            taiKhoanCoThueTTDB.Add("3332");

            System.Windows.Data.CollectionViewSource dm_TaiKhoanNoThueTTDB_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_ThueTTDB_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanNoThueTTDB_ListViewModel = ((List<object>)dm_TaiKhoanNoThueTTDB_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanNoThueTTDB_ListViewModel.filterDKNV(taiKhoanNoThueTTDB);

            System.Windows.Data.CollectionViewSource dm_TaiKhoanCoThueTTDB_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_ThueTTDB_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanCoThueTTDB_ListViewModel = ((List<object>)dm_TaiKhoanCoThueTTDB_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanCoThueTTDB_ListViewModel.filterDKNV(taiKhoanCoThueTTDB);

            taiKhoanNoChiTiet_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanNoChiTietChanged);
            taiKhoanCoChiTiet_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanCoChiTietChanged);
            taiKhoanNoThue_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanNoThueChanged);
            taiKhoanCoThue_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanCoThueChanged);
            taiKhoanNoChiPhiMuaHang_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanNoChiPhiMuaHangChanged);
            taiKhoanCoChiPhiMuaHang_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanCoChiPhiMuaHangChanged);
            taiKhoanNoTSThieuCXL_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanNoTSThieuCXLChanged);
            taiKhoanCoTSThieuCXL_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanCoTSThieuCXLChanged);
            taiKhoanNoTSThuaCXL_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanNoTSThuaCXLChanged);
            taiKhoanCoTSThuaCXL_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanCoTSThuaCXLChanged);
            taiKhoanNoThueNK_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanNoThueNKChanged);
            taiKhoanCoThueNK_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanCoThueNKChanged);
            taiKhoanNoThueTTDB_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanNoThueTTDBChanged);
            taiKhoanCoThueTTDB_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanCoThueTTDBChanged);
        }
        public void DoFilterDKNV8()
        {
            List<string> taiKhoanNoChiTiet = new List<string>();
            taiKhoanNoChiTiet.Add("151");
            taiKhoanNoChiTiet.Add("1521");
            taiKhoanNoChiTiet.Add("1531");
            taiKhoanNoChiTiet.Add("1561");
            taiKhoanNoChiTiet.Add("1567");
            taiKhoanNoChiTiet.Add("158");
            taiKhoanNoChiTiet.Add("611");
            taiKhoanNoChiTiet.Add("635");
            List<string> taiKhoanCoChiTiet = new List<string>();
            taiKhoanCoChiTiet.Add("1112");
            taiKhoanCoChiTiet.Add("1113");
            taiKhoanCoChiTiet.Add("1122");
            taiKhoanCoChiTiet.Add("1123");
            taiKhoanCoChiTiet.Add("515");
            taiKhoanCoChiTiet.Add("007");
            System.Windows.Data.CollectionViewSource dm_TaiKhoanNoChiTiet_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_ChiTiet_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanNoChiTiet_ListViewModel = ((List<object>)dm_TaiKhoanNoChiTiet_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanNoChiTiet_ListViewModel.filterDKNV(taiKhoanNoChiTiet);

            System.Windows.Data.CollectionViewSource dm_TaiKhoanCo_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_ChiTiet_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanCoChiTiet_ListViewModel = ((List<object>)dm_TaiKhoanCo_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanCoChiTiet_ListViewModel.filterDKNV(taiKhoanCoChiTiet);

            List<string> taiKhoanNoThue = new List<string>();
            taiKhoanNoThue.Add("1331");

            List<string> taiKhoanCoThue = new List<string>();
            taiKhoanCoThue.Add("33312");

            System.Windows.Data.CollectionViewSource dm_TaiKhoanNoThue_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_Thue_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanNoThue_ListViewModel = ((List<object>)dm_TaiKhoanNoThue_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanNoThue_ListViewModel.filterDKNV(taiKhoanNoThue);

            System.Windows.Data.CollectionViewSource dm_TaiKhoanCoThue_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_Thue_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanCoThue_ListViewModel = ((List<object>)dm_TaiKhoanCoThue_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanCoThue_ListViewModel.filterDKNV(taiKhoanCoThue);


            List<string> taiKhoanNoChiPhiMuaHang = new List<string>();
            taiKhoanNoChiPhiMuaHang.Add("151");
            taiKhoanNoChiPhiMuaHang.Add("1521");
            taiKhoanNoChiPhiMuaHang.Add("1531");
            taiKhoanNoChiPhiMuaHang.Add("1561");
            taiKhoanNoChiPhiMuaHang.Add("1567");
            taiKhoanNoChiPhiMuaHang.Add("158");
            taiKhoanNoChiPhiMuaHang.Add("611");

            List<string> taiKhoanCoChiPhiMuaHang = new List<string>();
            taiKhoanCoChiPhiMuaHang.Add("1522");
            taiKhoanCoChiPhiMuaHang.Add("1532");
            taiKhoanNoChiPhiMuaHang.Add("1562");

            System.Windows.Data.CollectionViewSource dm_TaiKhoanNoChiPhiMuaHang_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_ChiPhiMuaHang_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanNoChiPhiMuaHang_ListViewModel = ((List<object>)dm_TaiKhoanNoChiPhiMuaHang_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanNoChiPhiMuaHang_ListViewModel.filterDKNV(taiKhoanNoChiPhiMuaHang);

            System.Windows.Data.CollectionViewSource dm_TaiKhoanCoChiPhiMuaHang_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_ChiPhiMuaHang_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanCoChiPhiMuaHang_ListViewModel = ((List<object>)dm_TaiKhoanCoChiPhiMuaHang_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanCoChiPhiMuaHang_ListViewModel.filterDKNV(taiKhoanCoChiPhiMuaHang);

            List<string> taiKhoanNoTSThieuCXL = new List<string>();
            taiKhoanNoTSThieuCXL.Add("1381");
            taiKhoanNoTSThieuCXL.Add("635");

            List<string> taiKhoanCoTSThieuCXL = new List<string>();
            taiKhoanCoTSThieuCXL.Add("1111");
            taiKhoanCoTSThieuCXL.Add("1121");
            taiKhoanCoTSThieuCXL.Add("515");
            taiKhoanCoTSThieuCXL.Add("007");

            System.Windows.Data.CollectionViewSource dm_TaiKhoanNoTSThieuCXL_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_TSThieuCXL_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanNoTSThieuCXL_ListViewModel = ((List<object>)dm_TaiKhoanNoTSThieuCXL_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanNoTSThieuCXL_ListViewModel.filterDKNV(taiKhoanNoTSThieuCXL);

            System.Windows.Data.CollectionViewSource dm_TaiKhoanCoTSThieuCXL_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_TSThieuCXL_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanCoTSThieuCXL_ListViewModel = ((List<object>)dm_TaiKhoanCoTSThieuCXL_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanCoTSThieuCXL_ListViewModel.filterDKNV(taiKhoanCoTSThieuCXL);


            List<string> taiKhoanNoTSThuaCXL = new List<string>();
            taiKhoanNoTSThuaCXL.Add("1521");
            taiKhoanNoTSThuaCXL.Add("1531");
            taiKhoanNoTSThuaCXL.Add("1561");
            taiKhoanNoTSThuaCXL.Add("1567");
            taiKhoanNoTSThuaCXL.Add("158");
            taiKhoanNoTSThuaCXL.Add("611");

            List<string> taiKhoanCoTSThuaCXL = new List<string>();
            taiKhoanCoTSThuaCXL.Add("3381");

            System.Windows.Data.CollectionViewSource dm_TaiKhoanNoTSThuaCXL_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_TSThuaCXL_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanNoTSThuaCXL_ListViewModel = ((List<object>)dm_TaiKhoanNoTSThuaCXL_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanNoTSThuaCXL_ListViewModel.filterDKNV(taiKhoanNoTSThuaCXL);

            System.Windows.Data.CollectionViewSource dm_TaiKhoanCoTSThuaCXL_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_TSThuaCXL_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanCoTSThuaCXL_ListViewModel = ((List<object>)dm_TaiKhoanCoTSThuaCXL_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanCoTSThuaCXL_ListViewModel.filterDKNV(taiKhoanCoTSThuaCXL);


            List<string> taiKhoanNoThueNK = new List<string>();
            taiKhoanNoThueNK.Add("151");
            taiKhoanNoThueNK.Add("1521");
            taiKhoanNoThueNK.Add("1531");
            taiKhoanNoThueNK.Add("1561");
            taiKhoanNoThueNK.Add("1567");
            taiKhoanNoThueNK.Add("158");
            taiKhoanNoThueNK.Add("611");

            List<string> taiKhoanCoThueNK = new List<string>();
            taiKhoanCoThueNK.Add("3333");

            System.Windows.Data.CollectionViewSource dm_TaiKhoanNoThueNK_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_ThueNK_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanNoThueNK_ListViewModel = ((List<object>)dm_TaiKhoanNoThueNK_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanNoThueNK_ListViewModel.filterDKNV(taiKhoanNoThueNK);

            System.Windows.Data.CollectionViewSource dm_TaiKhoanCoThueNK_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_ThueNK_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanCoThueNK_ListViewModel = ((List<object>)dm_TaiKhoanCoThueNK_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanCoThueNK_ListViewModel.filterDKNV(taiKhoanCoThueNK);


            List<string> taiKhoanNoThueTTDB = new List<string>();
            taiKhoanNoThueTTDB.Add("151");
            taiKhoanNoThueTTDB.Add("1521");
            taiKhoanNoThueTTDB.Add("1531");
            taiKhoanNoThueTTDB.Add("1561");
            taiKhoanNoThueTTDB.Add("1567");
            taiKhoanNoThueTTDB.Add("158");
            taiKhoanNoThueTTDB.Add("611");

            List<string> taiKhoanCoThueTTDB = new List<string>();
            taiKhoanCoThueTTDB.Add("3332");

            System.Windows.Data.CollectionViewSource dm_TaiKhoanNoThueTTDB_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_ThueTTDB_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanNoThueTTDB_ListViewModel = ((List<object>)dm_TaiKhoanNoThueTTDB_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanNoThueTTDB_ListViewModel.filterDKNV(taiKhoanNoThueTTDB);

            System.Windows.Data.CollectionViewSource dm_TaiKhoanCoThueTTDB_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_ThueTTDB_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel taiKhoanCoThueTTDB_ListViewModel = ((List<object>)dm_TaiKhoanCoThueTTDB_ListViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            taiKhoanCoThueTTDB_ListViewModel.filterDKNV(taiKhoanCoThueTTDB);

            taiKhoanNoChiTiet_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanNoChiTietChanged);
            taiKhoanCoChiTiet_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanCoChiTietChanged);
            taiKhoanNoThue_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanNoThueChanged);
            taiKhoanCoThue_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanCoThueChanged);
            taiKhoanNoChiPhiMuaHang_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanNoChiPhiMuaHangChanged);
            taiKhoanCoChiPhiMuaHang_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanCoChiPhiMuaHangChanged);
            taiKhoanNoTSThieuCXL_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanNoTSThieuCXLChanged);
            taiKhoanCoTSThieuCXL_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanCoTSThieuCXLChanged);
            taiKhoanNoTSThuaCXL_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanNoTSThuaCXLChanged);
            taiKhoanCoTSThuaCXL_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanCoTSThuaCXLChanged);
            taiKhoanNoThueNK_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanNoThueNKChanged);
            taiKhoanCoThueNK_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanCoThueNKChanged);
            taiKhoanNoThueTTDB_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanNoThueTTDBChanged);
            taiKhoanCoThueTTDB_ListViewModel.ListTaiKhoanChanged += new EventHandler(OnTaiKhoanCoThueTTDBChanged);
        }



        private void OnTaiKhoanNoChiTietChanged(object sender, EventArgs e)
        {
            
            System.Windows.Data.CollectionViewSource dm_TKNo_ChiTiet_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_ChiTiet_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel dm_TKNo_ChiTiet_ListViewModel = ((List<object>)dm_TKNo_ChiTiet_CollectionViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            if( dm_TKNo_ChiTiet_ListViewModel.Model != null && GetViewModel().Model != null)
            {
                System.Collections.Generic.IList<DM_TaiKhoanInfo> listTKNo_ChiTiet = dm_TKNo_ChiTiet_ListViewModel.Model.getListOfInfo();
            
                IList<MSP_MuaHangHoa_ChiTietChild> list = this.GetViewModel().Model.MSP_MuaHangHoa_ChiTiets;
                foreach (MSP_MuaHangHoa_ChiTietChild item in list)
                {
                    item.TKNoId = listTKNo_ChiTiet[0].Khoa;
                }
            }
        }
            

        private void OnTaiKhoanNoThueChanged(object sender, EventArgs e)
        {
            System.Windows.Data.CollectionViewSource dm_TKNo_Thue_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_Thue_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel dm_TKNo_Thue_ListViewModel = ((List<object>)dm_TKNo_Thue_CollectionViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            if (dm_TKNo_Thue_ListViewModel.Model != null && GetViewModel().Model != null)
            {
                System.Collections.Generic.IList<DM_TaiKhoanInfo> listTKNo_Thue = dm_TKNo_Thue_ListViewModel.Model.getListOfInfo();
            
                IList<MSP_MuaHangHoa_ThueChild> list = this.GetViewModel().Model.MSP_MuaHangHoa_Thues;
                foreach (MSP_MuaHangHoa_ThueChild item in list)
                {
                    item.TKNoId = listTKNo_Thue[0].Khoa;
                }
            }
        }

        private void OnTaiKhoanNoChiPhiMuaHangChanged(object sender, EventArgs e)
        {
            System.Windows.Data.CollectionViewSource dm_TKNo_ChiPhiMuaHang_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_ChiPhiMuaHang_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel dm_TKNo_ChiPhiMuaHang_ListViewModel = ((List<object>)dm_TKNo_ChiPhiMuaHang_CollectionViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            if (dm_TKNo_ChiPhiMuaHang_ListViewModel.Model != null && GetViewModel().Model != null)
            {
                System.Collections.Generic.IList<DM_TaiKhoanInfo> listTKNo_ChiPhiMuaHang = dm_TKNo_ChiPhiMuaHang_ListViewModel.Model.getListOfInfo();

                IList<MSP_MuaHangHoa_ChiPhiMuaHangChild> list = this.GetViewModel().Model.MSP_MuaHangHoa_ChiPhiMuaHangs;
                foreach (MSP_MuaHangHoa_ChiPhiMuaHangChild item in list)
                {
                    item.TkNoId = listTKNo_ChiPhiMuaHang[0].Khoa;
                }
            }
        }

        private void OnTaiKhoanNoThueNKChanged(object sender, EventArgs e)
        {
            System.Windows.Data.CollectionViewSource dm_TKNo_ThueNK_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_ThueNK_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel dm_TKNo_ThueNK_ListViewModel = ((List<object>)dm_TKNo_ThueNK_CollectionViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            if (dm_TKNo_ThueNK_ListViewModel.Model != null && GetViewModel().Model != null)
            {
                System.Collections.Generic.IList<DM_TaiKhoanInfo> listTKNo_ThueNK = dm_TKNo_ThueNK_ListViewModel.Model.getListOfInfo();

                IList<MSP_MuaHangHoa_ThueNKChild> list = this.GetViewModel().Model.MSP_MuaHangHoa_ThueNKs;
                foreach (MSP_MuaHangHoa_ThueNKChild item in list)
                {
                    item.TkNoId = listTKNo_ThueNK[0].Khoa;
                }
            }
        }

        private void OnTaiKhoanNoThueTTDBChanged(object sender, EventArgs e)
        {
            System.Windows.Data.CollectionViewSource dm_TKNo_ThueTTDB_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_ThueTTDB_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel dm_TKNo_ThueTTDB_ListViewModel = ((List<object>)dm_TKNo_ThueTTDB_CollectionViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            if (dm_TKNo_ThueTTDB_ListViewModel.Model != null && GetViewModel().Model != null)
            {
                System.Collections.Generic.IList<DM_TaiKhoanInfo> listTKNo_ThueTTDB = dm_TKNo_ThueTTDB_ListViewModel.Model.getListOfInfo();

                IList<MSP_MuaHangHoa_ThueTTDBChild> list = this.GetViewModel().Model.MSP_MuaHangHoa_ThueTTDBs;
                foreach (MSP_MuaHangHoa_ThueTTDBChild item in list)
                {
                    item.TkNoId = listTKNo_ThueTTDB[0].Khoa;
                }
            }
        }

        private void OnTaiKhoanNoTSThieuCXLChanged(object sender, EventArgs e)
        {
            System.Windows.Data.CollectionViewSource dm_TKNo_TSThieuCXL_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_TSThieuCXL_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel dm_TKNo_TSThieuCXL_ListViewModel = ((List<object>)dm_TKNo_TSThieuCXL_CollectionViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            if (dm_TKNo_TSThieuCXL_ListViewModel.Model != null && GetViewModel().Model != null)
            {
                System.Collections.Generic.IList<DM_TaiKhoanInfo> listTKNo_TSThieuCXL = dm_TKNo_TSThieuCXL_ListViewModel.Model.getListOfInfo();

                IList<MSP_MuaHangHoa_TSThieuCXLChild> list = this.GetViewModel().Model.MSP_MuaHangHoa_TSThieuCXLs;
                foreach (MSP_MuaHangHoa_TSThieuCXLChild item in list)
                {
                    item.TkNoId = listTKNo_TSThieuCXL[0].Khoa;
                }
            }
        }

        private void OnTaiKhoanNoTSThuaCXLChanged(object sender, EventArgs e)
        {
            System.Windows.Data.CollectionViewSource dm_TKNo_TSThuaCXL_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanNo_TSThuaCXL_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel dm_TKNo_TSThuaCXL_ListViewModel = ((List<object>)dm_TKNo_TSThuaCXL_CollectionViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            if (dm_TKNo_TSThuaCXL_ListViewModel.Model != null && GetViewModel().Model != null)
            {
                System.Collections.Generic.IList<DM_TaiKhoanInfo> listTKNo_TSThuaCXL = dm_TKNo_TSThuaCXL_ListViewModel.Model.getListOfInfo();

                IList<MSP_MuaHangHoa_TSThuaCXLChild> list = this.GetViewModel().Model.MSP_MuaHangHoa_TSThuaCXLs;
                foreach (MSP_MuaHangHoa_TSThuaCXLChild item in list)
                {
                    item.TkNoId = listTKNo_TSThuaCXL[0].Khoa;
                }
            }
        }

        private void OnTaiKhoanCoChiTietChanged(object sender, EventArgs e)
        {
            System.Windows.Data.CollectionViewSource dm_TKCo_ChiTiet_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_ChiTiet_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel dm_TKCo_ChiTiet_ListViewModel = ((List<object>)dm_TKCo_ChiTiet_CollectionViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            if (dm_TKCo_ChiTiet_ListViewModel.Model != null && GetViewModel().Model != null)
            {
                System.Collections.Generic.IList<DM_TaiKhoanInfo> listTKCo_ChiTiet = dm_TKCo_ChiTiet_ListViewModel.Model.getListOfInfo();

                IList<MSP_MuaHangHoa_ChiTietChild> list = this.GetViewModel().Model.MSP_MuaHangHoa_ChiTiets;
                foreach (MSP_MuaHangHoa_ChiTietChild item in list)
                {
                    item.TKCoId = listTKCo_ChiTiet[0].Khoa;
                }
            }
        }

        private void OnTaiKhoanCoThueChanged(object sender, EventArgs e)
        {
            System.Windows.Data.CollectionViewSource dm_TKCo_Thue_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_Thue_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel dm_TKCo_Thue_ListViewModel = ((List<object>)dm_TKCo_Thue_CollectionViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            if (dm_TKCo_Thue_ListViewModel.Model != null && GetViewModel().Model != null)
            {
                System.Collections.Generic.IList<DM_TaiKhoanInfo> listTKCo_Thue = dm_TKCo_Thue_ListViewModel.Model.getListOfInfo();

                IList<MSP_MuaHangHoa_ThueChild> list = this.GetViewModel().Model.MSP_MuaHangHoa_Thues;
                foreach (MSP_MuaHangHoa_ThueChild item in list)
                {
                    item.TKCoId = listTKCo_Thue[0].Khoa;
                }
            }
        }

        private void OnTaiKhoanCoChiPhiMuaHangChanged(object sender, EventArgs e)
        {

            System.Windows.Data.CollectionViewSource dm_TKCo_ChiPhiMuaHang_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_ChiPhiMuaHang_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel dm_TKCo_ChiPhiMuaHang_ListViewModel = ((List<object>)dm_TKCo_ChiPhiMuaHang_CollectionViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            if (dm_TKCo_ChiPhiMuaHang_ListViewModel.Model != null && GetViewModel().Model != null)
            {
                System.Collections.Generic.IList<DM_TaiKhoanInfo> listTKCo_ChiPhiMuaHang = dm_TKCo_ChiPhiMuaHang_ListViewModel.Model.getListOfInfo();

                IList<MSP_MuaHangHoa_ChiPhiMuaHangChild> list = this.GetViewModel().Model.MSP_MuaHangHoa_ChiPhiMuaHangs;
                foreach (MSP_MuaHangHoa_ChiPhiMuaHangChild item in list)
                {
                    item.TkCoId = listTKCo_ChiPhiMuaHang[0].Khoa;
                }
            }
        }

        private void OnTaiKhoanCoThueNKChanged(object sender, EventArgs e)
        {
            System.Windows.Data.CollectionViewSource dm_TKCo_ThueNK_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_ThueNK_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel dm_TKCo_ThueNK_ListViewModel = ((List<object>)dm_TKCo_ThueNK_CollectionViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            if (dm_TKCo_ThueNK_ListViewModel.Model != null && GetViewModel().Model != null)
            {
                System.Collections.Generic.IList<DM_TaiKhoanInfo> listTKCo_ThueNK = dm_TKCo_ThueNK_ListViewModel.Model.getListOfInfo();

                IList<MSP_MuaHangHoa_ThueNKChild> list = this.GetViewModel().Model.MSP_MuaHangHoa_ThueNKs;
                foreach (MSP_MuaHangHoa_ThueNKChild item in list)
                {
                    item.TkCoId = listTKCo_ThueNK[0].Khoa;
                }
            }
        }

        private void OnTaiKhoanCoThueTTDBChanged(object sender, EventArgs e)
        {
            System.Windows.Data.CollectionViewSource dm_TKCo_ThueTTDB_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_ThueTTDB_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel dm_TKCo_ThueTTDB_ListViewModel = ((List<object>)dm_TKCo_ThueTTDB_CollectionViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            if (dm_TKCo_ThueTTDB_ListViewModel.Model != null && GetViewModel().Model != null)
            {
                System.Collections.Generic.IList<DM_TaiKhoanInfo> listTKCo_ThueTTDB = dm_TKCo_ThueTTDB_ListViewModel.Model.getListOfInfo();

                IList<MSP_MuaHangHoa_ThueTTDBChild> list = this.GetViewModel().Model.MSP_MuaHangHoa_ThueTTDBs;
                foreach (MSP_MuaHangHoa_ThueTTDBChild item in list)
                {
                    item.TkCoId = listTKCo_ThueTTDB[0].Khoa;
                }
            }
           
        }

        private void OnTaiKhoanCoTSThieuCXLChanged(object sender, EventArgs e)
        {
            System.Windows.Data.CollectionViewSource dm_TKCo_TSThieuCXL_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_TSThieuCXL_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel dm_TKCo_TSThieuCXL_ListViewModel = ((List<object>)dm_TKCo_TSThieuCXL_CollectionViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            if (dm_TKCo_TSThieuCXL_ListViewModel.Model != null && GetViewModel().Model != null)
            {
                System.Collections.Generic.IList<DM_TaiKhoanInfo> listTKCo_TSThieuCXL = dm_TKCo_TSThieuCXL_ListViewModel.Model.getListOfInfo();

                IList<MSP_MuaHangHoa_TSThieuCXLChild> list = this.GetViewModel().Model.MSP_MuaHangHoa_TSThieuCXLs;
                foreach (MSP_MuaHangHoa_TSThieuCXLChild item in list)
                {
                    item.TkCoId = listTKCo_TSThieuCXL[0].Khoa;
                }
            }
        }

        private void OnTaiKhoanCoTSThuaCXLChanged(object sender, EventArgs e)
        {
            System.Windows.Data.CollectionViewSource dm_TKCo_TSThuaCXL_CollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_TaiKhoanCo_TSThuaCXL_ListViewModelSource"];
            DM_TaiKhoan_ListViewModel dm_TKCo_TSThuaCXL_ListViewModel = ((List<object>)dm_TKCo_TSThuaCXL_CollectionViewSource.Source)[0] as DM_TaiKhoan_ListViewModel;
            if (dm_TKCo_TSThuaCXL_ListViewModel.Model != null && GetViewModel().Model != null)
            {
                System.Collections.Generic.IList<DM_TaiKhoanInfo> listTKCo_TSThuaCXL = dm_TKCo_TSThuaCXL_ListViewModel.Model.getListOfInfo();

                IList<MSP_MuaHangHoa_TSThuaCXLChild> list = this.GetViewModel().Model.MSP_MuaHangHoa_TSThuaCXLs;
                foreach (MSP_MuaHangHoa_TSThuaCXLChild item in list)
                {
                    item.TkCoId = listTKCo_TSThuaCXL[0].Khoa;
                }
            }
        
        }
        
        private void AddThueDetailsItem()
        {
            GetViewModel().AddMSP_MuaHangHoa_ThueItem();
        }

        private void AddMuaHangHoaDetailsItem()
        {
            GetViewModel().AddMSP_MuaHangHoa_ChiTietItem();
        }

        private void AddChiPhiMuaHangDetailsItem()
        {
            GetViewModel().AddMSP_MuaHangHoa_ChiPhiMuaHangItem();
        }

        private void AddTSThieuCXLDetailsItem()
        {
            GetViewModel().AddMSP_MuaHangHoa_TSThieuCXLItem();
        }

        private void AddTSThuaCXLDetailsItem()
        {
            GetViewModel().AddMSP_MuaHangHoa_TSThuaCXLItem();
        }

        private void AddThueNKDetailsItem()
        {
            GetViewModel().AddMSP_MuaHangHoa_ThueNKItem();
        }

        private void AddThueTTDBDetailsItem()
        {
            GetViewModel().AddMSP_MuaHangHoa_ThueTTDBItem();
        }

        private void DeleteThueDetailsItem(int Index)
        {
            GetViewModel().DeleteMSP_MuaHangHoa_ThueItem(Index);
        }

        private void DeleteMuaHangDetailsItem(int Index)
        {
            GetViewModel().DeleteMSP_MuaHangHoa_ChiTietItem( Index);
        }

        private void DeleteChiPhiMuaHangDetailsItem(int Index)
        {
            GetViewModel().DeleteMSP_MuaHangHoa_ChiPhiMuaHangItem(Index);
        }

        private void DeleteTSThieuCXLDetailsItem(int Index)
        {
            GetViewModel().DeleteMSP_MuaHangHoa_TSThieuCXLItem(Index);
        }

        private void DeleteTSThuaCXLDetailsItem(int Index)
        {
            GetViewModel().DeleteMSP_MuaHangHoa_TSThuaCXLItem(Index);
        }

        private void DeleteThueNKDetailsItem(int Index)
        {
            GetViewModel().DeleteMSP_MuaHangHoa_ThueNKItem(Index);
        }

        private void DeleteThueTTDBDetailsItem(int Index)
        {
            GetViewModel().DeleteMSP_MuaHangHoa_ThueTTDBItem(Index);
        }

        void msp_MuaHangHoa_ViewModel_ChildList_AddedNew(object sender, ChildListAddedNewArgs e)
        {
            if (e.ChildListName == "MSP_MuaHangHoa_ChiTiets")
            {
                this.MSP_MuaHangHoa_MuaHangHoaChiTietGridView.OnAddingNewDataItem(new GridViewAddingNewEventArgs(GetActiveGridView()));
            }
            else if (e.ChildListName == "MSP_MuaHangHoa_Thues")
            {
                this.MSP_MuaHangHoa_ChiPhiMuaHangGridView.OnAddingNewDataItem(new GridViewAddingNewEventArgs(GetActiveGridView()));
            }
            else if (e.ChildListName == "MSP_MuaHangHoa_ChiPhiMuaHangs")
            {
                this.MSP_MuaHangHoa_ChiPhiMuaHangGridView.OnAddingNewDataItem(new GridViewAddingNewEventArgs(GetActiveGridView()));
            }
            else if (e.ChildListName == "MSP_MuaHangHoa_TSThieuCXLs")
            {
                this.MSP_MuaHangHoa_TSThieuCXLGridView.OnAddingNewDataItem(new GridViewAddingNewEventArgs(GetActiveGridView()));
            }
            else if (e.ChildListName == "MSP_MuaHangHoa_TSThuaCXLs")
            {
                this.MSP_MuaHangHoa_TSThuaCXLGridView.OnAddingNewDataItem(new GridViewAddingNewEventArgs(GetActiveGridView()));
            }
            else if (e.ChildListName == "MSP_MuaHangHoa_ThueNKs")
            {
                this.MSP_MuaHangHoa_ThueNKGridView.OnAddingNewDataItem(new GridViewAddingNewEventArgs(GetActiveGridView()));
            }
            else if (e.ChildListName == "MSP_MuaHangHoa_ThueTTDBs")
            {
                this.MSP_MuaHangHoa_ThueTTDBGridView.OnAddingNewDataItem(new GridViewAddingNewEventArgs(GetActiveGridView()));
            }
        }

       
       
        #endregion

       
    }
}
